]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/flockfile.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / LibC / Stdio / flockfile.c
diff --git a/StdLib/LibC/Stdio/flockfile.c b/StdLib/LibC/Stdio/flockfile.c
deleted file mode 100644 (file)
index 386164e..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*  $NetBSD: flockfile.c,v 1.8 2003/07/22 00:56:25 nathanw Exp $  */\r
-\r
-/*-\r
- * Copyright (c) 2002 The NetBSD Foundation, Inc.\r
- * All rights reserved.\r
- *\r
- * This code is derived from software contributed to The NetBSD Foundation\r
- * by Nathan J. Williams.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- *    notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the\r
- *    documentation and/or other materials provided with the distribution.\r
- * 3. All advertising materials mentioning features or use of this software\r
- *    must display the following acknowledgement:\r
- *        This product includes software developed by the NetBSD\r
- *        Foundation, Inc. and its contributors.\r
- * 4. Neither the name of The NetBSD Foundation nor the names of its\r
- *    contributors may be used to endorse or promote products derived\r
- *    from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\r
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\r
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
- * POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-#include  <LibConfig.h>\r
-#include <sys/EfiCdefs.h>\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: flockfile.c,v 1.8 2003/07/22 00:56:25 nathanw Exp $");\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include "namespace.h"\r
-\r
-#include <assert.h>\r
-#include <errno.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include "reentrant.h"\r
-#include "local.h"\r
-\r
-#ifdef __weak_alias\r
-__weak_alias(flockfile,_flockfile)\r
-__weak_alias(ftrylockfile,_ftrylockfile)\r
-__weak_alias(funlockfile,_funlockfile)\r
-#endif\r
-\r
-#ifdef _REENTRANT\r
-/*\r
- * XXX This code makes the assumption that a thr_t (pthread_t) is a\r
- * XXX pointer.\r
- */\r
-\r
-extern int __isthreaded;\r
-\r
-void\r
-flockfile(FILE *fp)\r
-{\r
-\r
-  __flockfile_internal(fp, 0);\r
-}\r
-\r
-int\r
-ftrylockfile(FILE *fp)\r
-{\r
-  int retval;\r
-\r
-  if (__isthreaded == 0)\r
-    return 0;\r
-\r
-  retval = 0;\r
-  mutex_lock(&_LOCK(fp));\r
-\r
-  if (_LOCKOWNER(fp) == thr_self()) {\r
-    _LOCKCOUNT(fp)++;\r
-  } else if (_LOCKOWNER(fp) == NULL) {\r
-    _LOCKOWNER(fp) = thr_self();\r
-    _LOCKCOUNT(fp) = 1;\r
-  } else\r
-    retval = -1;\r
-\r
-  mutex_unlock(&_LOCK(fp));\r
-\r
-  return retval;\r
-}\r
-\r
-void\r
-funlockfile(FILE *fp)\r
-{\r
-\r
-  __funlockfile_internal(fp, 0);\r
-}\r
-\r
-void\r
-__flockfile_internal(FILE *fp, int internal)\r
-{\r
-\r
-  if (__isthreaded == 0)\r
-    return;\r
-\r
-  mutex_lock(&_LOCK(fp));\r
-\r
-  if (_LOCKOWNER(fp) == thr_self()) {\r
-    _LOCKCOUNT(fp)++;\r
-    if (internal)\r
-      _LOCKINTERNAL(fp)++;\r
-  } else {\r
-    /* danger! cond_wait() is a cancellation point. */\r
-    int oldstate;\r
-    thr_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);\r
-    while (_LOCKOWNER(fp) != NULL)\r
-      cond_wait(&_LOCKCOND(fp), &_LOCK(fp));\r
-    thr_setcancelstate(oldstate, NULL);\r
-    _LOCKOWNER(fp) = thr_self();\r
-    _LOCKCOUNT(fp) = 1;\r
-    if (internal)\r
-      _LOCKINTERNAL(fp) = 1;\r
-  }\r
-\r
-  if (_LOCKINTERNAL(fp) == 1)\r
-    /* stash cancellation state and disable */\r
-    thr_setcancelstate(PTHREAD_CANCEL_DISABLE,\r
-        &_LOCKCANCELSTATE(fp));\r
-\r
-  mutex_unlock(&_LOCK(fp));\r
-}\r
-\r
-void\r
-__funlockfile_internal(FILE *fp, int internal)\r
-{\r
-\r
-  if (__isthreaded == 0)\r
-    return;\r
-\r
-  mutex_lock(&_LOCK(fp));\r
-\r
-  if (internal) {\r
-    _LOCKINTERNAL(fp)--;\r
-    if (_LOCKINTERNAL(fp) == 0)\r
-      thr_setcancelstate(_LOCKCANCELSTATE(fp), NULL);\r
-  }\r
-\r
-  _LOCKCOUNT(fp)--;\r
-  if (_LOCKCOUNT(fp) == 0) {\r
-    _LOCKOWNER(fp) = NULL;\r
-    cond_signal(&_LOCKCOND(fp));\r
-  }\r
-\r
-  mutex_unlock(&_LOCK(fp));\r
-}\r
-\r
-#else /* _REENTRANT */\r
-\r
-void\r
-flockfile(FILE *fp)\r
-{\r
-  /* LINTED deliberate lack of effect */\r
-  (void)fp;\r
-\r
-  return;\r
-}\r
-\r
-int\r
-ftrylockfile(FILE *fp)\r
-{\r
-  /* LINTED deliberate lack of effect */\r
-  (void)fp;\r
-\r
-  return (0);\r
-}\r
-\r
-void\r
-funlockfile(FILE *fp)\r
-{\r
-  /* LINTED deliberate lack of effect */\r
-  (void)fp;\r
-\r
-  return;\r
-}\r
-\r
-#endif /* _REENTRANT */\r