diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-05-23 00:11:01 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-05-23 00:20:38 +0300 |
commit | b975e6ab4f0b571dea152efe2dd2c37b8e61ec11 (patch) | |
tree | 1dcb7f32236850edc04658ccc3c2db2e04071208 | |
parent | 2db00937d0f8047775b8c0ac8dd53b6ad0a29b89 (diff) | |
download | ydb-b975e6ab4f0b571dea152efe2dd2c37b8e61ec11.tar.gz |
Remove more unused gnulib sources
7dedc56d9c3dca7ed4ff1387f800c2f60338c0ee
39 files changed, 5 insertions, 4833 deletions
diff --git a/contrib/tools/bison/lib/bison-system.h b/contrib/tools/bison/lib/bison-system.h deleted file mode 100644 index 472a1921a7..0000000000 --- a/contrib/tools/bison/lib/bison-system.h +++ /dev/null @@ -1,264 +0,0 @@ -/* System-dependent definitions for Bison. - - Copyright (C) 2000-2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef BISON_SYSTEM_H -# define BISON_SYSTEM_H - -/* flex 2.5.31 gratutiously defines macros like INT8_MIN. But this - runs afoul of pre-C99 compilers that have <inttypes.h> or - <stdint.h>, which are included below if available. It also runs - afoul of pre-C99 compilers that define these macros in <limits.h>. */ -# if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901 -# undef INT8_MIN -# undef INT16_MIN -# undef INT32_MIN -# undef INT8_MAX -# undef INT16_MAX -# undef UINT8_MAX -# undef INT32_MAX -# undef UINT16_MAX -# undef UINT32_MAX -# endif - -# include <limits.h> -# include <stddef.h> -# include <stdlib.h> -# include <string.h> - -# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) -# define STREQ(L, R) (strcmp(L, R) == 0) -# define STRNEQ(L, R) (!STREQ(L, R)) - -/* Just like strncmp, but the second argument must be a literal string - and you don't specify the length. */ -# define STRNCMP_LIT(S, Literal) \ - strncmp (S, "" Literal "", sizeof (Literal) - 1) - -/* Whether Literal is a prefix of S. */ -# define STRPREFIX_LIT(Literal, S) \ - (STRNCMP_LIT (S, Literal) == 0) - -# include <unistd.h> -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else -# include <inttypes.h> -#endif - -# ifndef UINTPTR_MAX -/* This isn't perfect, but it's good enough for Bison, which needs - only to hash pointers. */ -typedef size_t uintptr_t; -# endif - -/* Version mismatch. */ -# define EX_MISMATCH 63 - -/*---------. -| Gnulib. | -`---------*/ - -# include <unlocked-io.h> -# include <verify.h> -# include <xalloc.h> - - -/*-----------------. -| GCC extensions. | -`-----------------*/ - -/* Use PACIFY_CC to indicate that Code is unimportant to the logic of Bison - but that it is necessary for suppressing compiler warnings. For example, - Code might be a variable initializer that's always overwritten before the - variable is used. - - PACIFY_CC is intended to be useful only as a comment as it does not alter - Code. It is tempting to redefine PACIFY_CC so that it will suppress Code - when configuring without --enable-gcc-warnings. However, that would mean - that, for maintainers, Bison would compile with potentially less warnings - and safer logic than it would for users. Due to the overhead of M4, - suppressing Code is unlikely to offer any significant improvement in - Bison's performance anyway. */ -# define PACIFY_CC(Code) Code - -# ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ -# endif -# endif - -/* The __-protected variants of 'format' and 'printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif - -# ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) -# endif - -# ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -# endif - - -/*------. -| NLS. | -`------*/ - -# include <locale.h> - -# include <gettext.h> -# define _(Msgid) gettext (Msgid) -# define N_(Msgid) (Msgid) - - -/*-----------. -| Booleans. | -`-----------*/ - -# include <stdbool.h> - - - -/*-------------. -| Assertions. | -`-------------*/ - -/* In the past, Bison defined aver to simply invoke abort in the case of - a failed assertion. The rationale was that <assert.h>'s assertions - were too heavyweight and could be disabled too easily. See - discussions at - <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00080.html> - <http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00111.html>. - - However, normal assert output can be helpful during development and - in bug reports from users. Moreover, it's not clear now that - <assert.h>'s assertions are significantly heavyweight. Finally, if - users want to experiment with disabling assertions, it's debatable - whether it's our responsibility to stop them. See discussion - starting at - <http://lists.gnu.org/archive/html/bison-patches/2009-09/msg00013.html>. - - For now, we use assert but we call it aver throughout Bison in case - we later wish to try another scheme. -*/ -# include <assert.h> -# define aver assert - - -/*-----------. -| Obstacks. | -`-----------*/ - -# define obstack_chunk_alloc xmalloc -# define obstack_chunk_free free -# include <obstack.h> - -/* String-grow: append Str to Obs. */ - -# define obstack_sgrow(Obs, Str) \ - obstack_grow (Obs, Str, strlen (Str)) - -/* Output Str escaped for our postprocessing (i.e., escape M4 special - characters). - - For instance "[foo]" -> "@{foo@}", "$$" -> "$][$][". */ - -# define obstack_escape(Obs, Str) \ - do { \ - char const *p__; \ - for (p__ = Str; *p__; p__++) \ - switch (*p__) \ - { \ - case '$': obstack_sgrow (Obs, "$]["); break; \ - case '@': obstack_sgrow (Obs, "@@" ); break; \ - case '[': obstack_sgrow (Obs, "@{" ); break; \ - case ']': obstack_sgrow (Obs, "@}" ); break; \ - default: obstack_1grow (Obs, *p__ ); break; \ - } \ - } while (0) - - -/* Output Str both quoted for M4 (i.e., embed in [[...]]), and escaped - for our postprocessing (i.e., escape M4 special characters). If - Str is empty (or NULL), output "[]" instead of "[[]]" as it make M4 - programming easier (m4_ifval can be used). - - For instance "[foo]" -> "[[@{foo@}]]", "$$" -> "[[$][$][]]". */ - -# define obstack_quote(Obs, Str) \ - do { \ - char const* obstack_quote_p = Str; \ - if (obstack_quote_p && obstack_quote_p[0]) \ - { \ - obstack_sgrow (Obs, "[["); \ - obstack_escape (Obs, obstack_quote_p); \ - obstack_sgrow (Obs, "]]"); \ - } \ - else \ - obstack_sgrow (Obs, "[]"); \ - } while (0) - - -/* Append the ending 0, finish Obs, and return the string. */ - -# define obstack_finish0(Obs) \ - (obstack_1grow (Obs, '\0'), (char *) obstack_finish (Obs)) - - -/*-----------------------------------------. -| Extensions to use for the output files. | -`-----------------------------------------*/ - -# ifndef OUTPUT_EXT -# define OUTPUT_EXT ".output" -# endif - -# ifndef TAB_EXT -# define TAB_EXT ".tab" -# endif - - - -/*---------------------. -| Free a linked list. | -`---------------------*/ - -# define LIST_FREE(Type, List) \ - do { \ - Type *_node, *_next; \ - for (_node = List; _node; _node = _next) \ - { \ - _next = _node->next; \ - free (_node); \ - } \ - } while (0) - - -/*---------------------------------------------. -| Debugging memory allocation (must be last). | -`---------------------------------------------*/ - -# if WITH_DMALLOC -# define DMALLOC_FUNC_CHECK -# include <dmalloc.h> -# endif /* WITH_DMALLOC */ - -#endif /* ! BISON_SYSTEM_H */ diff --git a/contrib/tools/bison/lib/fstat.c b/contrib/tools/bison/lib/fstat.c deleted file mode 100644 index dc802f502b..0000000000 --- a/contrib/tools/bison/lib/fstat.c +++ /dev/null @@ -1,88 +0,0 @@ -/* fstat() replacement. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* If the user's config.h happens to include <sys/stat.h>, let it include only - the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to - rpl_fstat. */ -#define __need_system_sys_stat_h -#include <config.h> - -/* Get the original definition of fstat. It might be defined as a macro. */ -#include <sys/types.h> -#include <sys/stat.h> -#if _GL_WINDOWS_64_BIT_ST_SIZE -# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ -# define stat _stati64 -# undef fstat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ -# define fstat _fstati64 -#endif -#undef __need_system_sys_stat_h - -static int -orig_fstat (int fd, struct stat *buf) -{ - return fstat (fd, buf); -} - -/* Specification. */ -/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc - eliminates this include because of the preliminary #include <sys/stat.h> - above. */ -#include "sys/stat.h" - -#include <errno.h> -#include <unistd.h> - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER -# include "msvc-inval.h" -#endif - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER -static int -fstat_nothrow (int fd, struct stat *buf) -{ - int result; - - TRY_MSVC_INVAL - { - result = orig_fstat (fd, buf); - } - CATCH_MSVC_INVAL - { - result = -1; - errno = EBADF; - } - DONE_MSVC_INVAL; - - return result; -} -#else -# define fstat_nothrow orig_fstat -#endif - -int -rpl_fstat (int fd, struct stat *buf) -{ -#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY - /* Handle the case when rpl_open() used a dummy file descriptor to work - around an open() that can't normally visit directories. */ - const char *name = _gl_directory_name (fd); - if (name != NULL) - return stat (name, buf); -#endif - - return fstat_nothrow (fd, buf); -} diff --git a/contrib/tools/bison/lib/glthread/lock.h b/contrib/tools/bison/lib/glthread/lock.h deleted file mode 100644 index 42228df80f..0000000000 --- a/contrib/tools/bison/lib/glthread/lock.h +++ /dev/null @@ -1,927 +0,0 @@ -/* Locking in multithreaded situations. - Copyright (C) 2005-2013 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2005. - Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, - gthr-win32.h. */ - -/* This file contains locking primitives for use with a given thread library. - It does not contain primitives for creating threads or for other - synchronization primitives. - - Normal (non-recursive) locks: - Type: gl_lock_t - Declaration: gl_lock_define(extern, name) - Initializer: gl_lock_define_initialized(, name) - Initialization: gl_lock_init (name); - Taking the lock: gl_lock_lock (name); - Releasing the lock: gl_lock_unlock (name); - De-initialization: gl_lock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_lock_init (&name); - Taking the lock: err = glthread_lock_lock (&name); - Releasing the lock: err = glthread_lock_unlock (&name); - De-initialization: err = glthread_lock_destroy (&name); - - Read-Write (non-recursive) locks: - Type: gl_rwlock_t - Declaration: gl_rwlock_define(extern, name) - Initializer: gl_rwlock_define_initialized(, name) - Initialization: gl_rwlock_init (name); - Taking the lock: gl_rwlock_rdlock (name); - gl_rwlock_wrlock (name); - Releasing the lock: gl_rwlock_unlock (name); - De-initialization: gl_rwlock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_rwlock_init (&name); - Taking the lock: err = glthread_rwlock_rdlock (&name); - err = glthread_rwlock_wrlock (&name); - Releasing the lock: err = glthread_rwlock_unlock (&name); - De-initialization: err = glthread_rwlock_destroy (&name); - - Recursive locks: - Type: gl_recursive_lock_t - Declaration: gl_recursive_lock_define(extern, name) - Initializer: gl_recursive_lock_define_initialized(, name) - Initialization: gl_recursive_lock_init (name); - Taking the lock: gl_recursive_lock_lock (name); - Releasing the lock: gl_recursive_lock_unlock (name); - De-initialization: gl_recursive_lock_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_recursive_lock_init (&name); - Taking the lock: err = glthread_recursive_lock_lock (&name); - Releasing the lock: err = glthread_recursive_lock_unlock (&name); - De-initialization: err = glthread_recursive_lock_destroy (&name); - - Once-only execution: - Type: gl_once_t - Initializer: gl_once_define(extern, name) - Execution: gl_once (name, initfunction); - Equivalent functions with control of error handling: - Execution: err = glthread_once (&name, initfunction); -*/ - - -#ifndef _LOCK_H -#define _LOCK_H - -#include <errno.h> -#include <stdlib.h> - -/* ========================================================================= */ - -#if USE_POSIX_THREADS - -/* Use the POSIX threads library. */ - -# include <pthread.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if PTHREAD_IN_USE_DETECTION_HARD - -/* The pthread_in_use() detection needs to be done at runtime. */ -# define pthread_in_use() \ - glthread_in_use () -extern int glthread_in_use (void); - -# endif - -# if USE_POSIX_THREADS_WEAK - -/* Use weak references to the POSIX threads library. */ - -/* Weak references avoid dragging in external libraries if the other parts - of the program don't use them. Here we use them, because we don't want - every program that uses libintl to depend on libpthread. This assumes - that libpthread would not be loaded after libintl; i.e. if libintl is - loaded first, by an executable that does not depend on libpthread, and - then a module is dynamically loaded that depends on libpthread, libintl - will not be multithread-safe. */ - -/* The way to test at runtime whether libpthread is present is to test - whether a function pointer's value, such as &pthread_mutex_init, is - non-NULL. However, some versions of GCC have a bug through which, in - PIC mode, &foo != NULL always evaluates to true if there is a direct - call to foo(...) in the same function. To avoid this, we test the - address of a function in libpthread that we don't use. */ - -# pragma weak pthread_mutex_init -# pragma weak pthread_mutex_lock -# pragma weak pthread_mutex_unlock -# pragma weak pthread_mutex_destroy -# pragma weak pthread_rwlock_init -# pragma weak pthread_rwlock_rdlock -# pragma weak pthread_rwlock_wrlock -# pragma weak pthread_rwlock_unlock -# pragma weak pthread_rwlock_destroy -# pragma weak pthread_once -# pragma weak pthread_cond_init -# pragma weak pthread_cond_wait -# pragma weak pthread_cond_signal -# pragma weak pthread_cond_broadcast -# pragma weak pthread_cond_destroy -# pragma weak pthread_mutexattr_init -# pragma weak pthread_mutexattr_settype -# pragma weak pthread_mutexattr_destroy -# ifndef pthread_self -# pragma weak pthread_self -# endif - -# if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) -# endif - -# else - -# if !PTHREAD_IN_USE_DETECTION_HARD -# define pthread_in_use() 1 -# endif - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef pthread_mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - PTHREAD_MUTEX_INITIALIZER -# define glthread_lock_init(LOCK) \ - (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0) -# define glthread_lock_lock(LOCK) \ - (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) -# define glthread_lock_unlock(LOCK) \ - (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) -# define glthread_lock_destroy(LOCK) \ - (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -# if HAVE_PTHREAD_RWLOCK - -# ifdef PTHREAD_RWLOCK_INITIALIZER - -typedef pthread_rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - PTHREAD_RWLOCK_INITIALIZER -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0) - -# else - -typedef struct - { - int initialized; - pthread_mutex_t guard; /* protects the initialization */ - pthread_rwlock_t rwlock; /* read-write lock */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { 0, PTHREAD_MUTEX_INITIALIZER } -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -# else - -typedef struct - { - pthread_mutex_t lock; /* protects the remaining fields */ - pthread_cond_t waiting_readers; /* waiting readers */ - pthread_cond_t waiting_writers; /* waiting writers */ - unsigned int waiting_writers_count; /* number of waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } -# define glthread_rwlock_init(LOCK) \ - (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -# if HAVE_PTHREAD_MUTEX_RECURSIVE - -# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - -typedef pthread_mutex_t gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; -# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER -# define gl_recursive_lock_initializer \ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER -# else -# define gl_recursive_lock_initializer \ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -# endif -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); - -# else - -typedef struct - { - pthread_mutex_t recmutex; /* recursive mutex */ - pthread_mutex_t guard; /* protects the initialization */ - int initialized; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -# endif - -# else - -/* Old versions of POSIX threads on Solaris did not have recursive locks. - We have to implement them ourselves. */ - -typedef struct - { - pthread_mutex_t mutex; - pthread_t owner; - unsigned long depth; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -# endif - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef pthread_once_t gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pthread_in_use () \ - ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_singlethreaded (pthread_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_mutex_init -# pragma weak pth_mutex_acquire -# pragma weak pth_mutex_release -# pragma weak pth_rwlock_init -# pragma weak pth_rwlock_acquire -# pragma weak pth_rwlock_release -# pragma weak pth_once - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL) - -# else - -# define pth_in_use() 1 - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef pth_mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -typedef pth_rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - PTH_RWLOCK_INIT -# define glthread_rwlock_init(LOCK) \ - (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0) -# define glthread_rwlock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* In Pth, mutexes are recursive by default. */ -typedef pth_mutex_t gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_recursive_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef pth_once_t gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pth_in_use () \ - ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)); -extern int glthread_once_singlethreaded (pth_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_SOLARIS_THREADS - -/* Use the old Solaris threads library. */ - -# include <thread.h> -# error #include <synch.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_SOLARIS_THREADS_WEAK - -/* Use weak references to the old Solaris threads library. */ - -# pragma weak mutex_init -# pragma weak mutex_lock -# pragma weak mutex_unlock -# pragma weak mutex_destroy -# pragma weak rwlock_init -# pragma weak rw_rdlock -# pragma weak rw_wrlock -# pragma weak rw_unlock -# pragma weak rwlock_destroy -# pragma weak thr_self - -# pragma weak thr_suspend -# define thread_in_use() (thr_suspend != NULL) - -# else - -# define thread_in_use() 1 - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - DEFAULTMUTEX -# define glthread_lock_init(LOCK) \ - (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0) -# define glthread_lock_lock(LOCK) \ - (thread_in_use () ? mutex_lock (LOCK) : 0) -# define glthread_lock_unlock(LOCK) \ - (thread_in_use () ? mutex_unlock (LOCK) : 0) -# define glthread_lock_destroy(LOCK) \ - (thread_in_use () ? mutex_destroy (LOCK) : 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -typedef rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - DEFAULTRWLOCK -# define glthread_rwlock_init(LOCK) \ - (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (thread_in_use () ? rw_rdlock (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (thread_in_use () ? rw_wrlock (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (thread_in_use () ? rw_unlock (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (thread_in_use () ? rwlock_destroy (LOCK) : 0) - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* Old Solaris threads did not have recursive locks. - We have to implement them ourselves. */ - -typedef struct - { - mutex_t mutex; - thread_t owner; - unsigned long depth; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { DEFAULTMUTEX, (thread_t) 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) -extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef struct - { - volatile int inited; - mutex_t mutex; - } - gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (thread_in_use () \ - ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)); -extern int glthread_once_singlethreaded (gl_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if USE_WINDOWS_THREADS - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> - -# ifdef __cplusplus -extern "C" { -# endif - -/* We can use CRITICAL_SECTION directly, rather than the native Windows Event, - Mutex, Semaphore types, because - - we need only to synchronize inside a single process (address space), - not inter-process locking, - - we don't need to support trylock operations. (TryEnterCriticalSection - does not work on Windows 95/98/ME. Packages that need trylock usually - define their own mutex type.) */ - -/* There is no way to statically initialize a CRITICAL_SECTION. It needs - to be done lazily, once only. For this we need spinlocks. */ - -typedef struct { volatile int done; volatile long started; } gl_spinlock_t; - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - CRITICAL_SECTION lock; - } - gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_lock_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_lock_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - { { 0, -1 } } -# define glthread_lock_init(LOCK) \ - (glthread_lock_init_func (LOCK), 0) -# define glthread_lock_lock(LOCK) \ - glthread_lock_lock_func (LOCK) -# define glthread_lock_unlock(LOCK) \ - glthread_lock_unlock_func (LOCK) -# define glthread_lock_destroy(LOCK) \ - glthread_lock_destroy_func (LOCK) -extern void glthread_lock_init_func (gl_lock_t *lock); -extern int glthread_lock_lock_func (gl_lock_t *lock); -extern int glthread_lock_unlock_func (gl_lock_t *lock); -extern int glthread_lock_destroy_func (gl_lock_t *lock); - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* It is impossible to implement read-write locks using plain locks, without - introducing an extra thread dedicated to managing read-write locks. - Therefore here we need to use the low-level Event type. */ - -typedef struct - { - HANDLE *array; /* array of waiting threads, each represented by an event */ - unsigned int count; /* number of waiting threads */ - unsigned int alloc; /* length of allocated array */ - unsigned int offset; /* index of first waiting thread in array */ - } - gl_carray_waitqueue_t; -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - CRITICAL_SECTION lock; /* protects the remaining fields */ - gl_carray_waitqueue_t waiting_readers; /* waiting readers */ - gl_carray_waitqueue_t waiting_writers; /* waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { { 0, -1 } } -# define glthread_rwlock_init(LOCK) \ - (glthread_rwlock_init_func (LOCK), 0) -# define glthread_rwlock_rdlock(LOCK) \ - glthread_rwlock_rdlock_func (LOCK) -# define glthread_rwlock_wrlock(LOCK) \ - glthread_rwlock_wrlock_func (LOCK) -# define glthread_rwlock_unlock(LOCK) \ - glthread_rwlock_unlock_func (LOCK) -# define glthread_rwlock_destroy(LOCK) \ - glthread_rwlock_destroy_func (LOCK) -extern void glthread_rwlock_init_func (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* The native Windows documentation says that CRITICAL_SECTION already - implements a recursive lock. But we need not rely on it: It's easy to - implement a recursive lock without this assumption. */ - -typedef struct - { - gl_spinlock_t guard; /* protects the initialization */ - DWORD owner; - unsigned long depth; - CRITICAL_SECTION lock; - } - gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - { { 0, -1 }, 0, 0 } -# define glthread_recursive_lock_init(LOCK) \ - (glthread_recursive_lock_init_func (LOCK), 0) -# define glthread_recursive_lock_lock(LOCK) \ - glthread_recursive_lock_lock_func (LOCK) -# define glthread_recursive_lock_unlock(LOCK) \ - glthread_recursive_lock_unlock_func (LOCK) -# define glthread_recursive_lock_destroy(LOCK) \ - glthread_recursive_lock_destroy_func (LOCK) -extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock); -extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock); - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef struct - { - volatile int inited; - volatile long started; - CRITICAL_SECTION lock; - } - gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = { -1, -1 }; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) -extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) - -/* Provide dummy implementation if threads are not supported. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef int gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) -# define gl_lock_define_initialized(STORAGECLASS, NAME) -# define glthread_lock_init(NAME) 0 -# define glthread_lock_lock(NAME) 0 -# define glthread_lock_unlock(NAME) 0 -# define glthread_lock_destroy(NAME) 0 - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -typedef int gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) -# define glthread_rwlock_init(NAME) 0 -# define glthread_rwlock_rdlock(NAME) 0 -# define glthread_rwlock_wrlock(NAME) 0 -# define glthread_rwlock_unlock(NAME) 0 -# define glthread_rwlock_destroy(NAME) 0 - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -typedef int gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) -# define glthread_recursive_lock_init(NAME) 0 -# define glthread_recursive_lock_lock(NAME) 0 -# define glthread_recursive_lock_unlock(NAME) 0 -# define glthread_recursive_lock_destroy(NAME) 0 - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef int gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_once_t NAME = 0; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0) - -#endif - -/* ========================================================================= */ - -/* Macros with built-in error handling. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -#define gl_lock_init(NAME) \ - do \ - { \ - if (glthread_lock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_lock(NAME) \ - do \ - { \ - if (glthread_lock_lock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_unlock(NAME) \ - do \ - { \ - if (glthread_lock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_lock_destroy(NAME) \ - do \ - { \ - if (glthread_lock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -#define gl_rwlock_init(NAME) \ - do \ - { \ - if (glthread_rwlock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_rdlock(NAME) \ - do \ - { \ - if (glthread_rwlock_rdlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_wrlock(NAME) \ - do \ - { \ - if (glthread_rwlock_wrlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_unlock(NAME) \ - do \ - { \ - if (glthread_rwlock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_rwlock_destroy(NAME) \ - do \ - { \ - if (glthread_rwlock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -#define gl_recursive_lock_init(NAME) \ - do \ - { \ - if (glthread_recursive_lock_init (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_lock(NAME) \ - do \ - { \ - if (glthread_recursive_lock_lock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_unlock(NAME) \ - do \ - { \ - if (glthread_recursive_lock_unlock (&NAME)) \ - abort (); \ - } \ - while (0) -#define gl_recursive_lock_destroy(NAME) \ - do \ - { \ - if (glthread_recursive_lock_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* -------------------------- gl_once_t datatype -------------------------- */ - -#define gl_once(NAME, INITFUNCTION) \ - do \ - { \ - if (glthread_once (&NAME, INITFUNCTION)) \ - abort (); \ - } \ - while (0) - -/* ========================================================================= */ - -#endif /* _LOCK_H */ diff --git a/contrib/tools/bison/lib/glthread/tls.h b/contrib/tools/bison/lib/glthread/tls.h deleted file mode 100644 index 2afe0b43c3..0000000000 --- a/contrib/tools/bison/lib/glthread/tls.h +++ /dev/null @@ -1,299 +0,0 @@ -/* Thread-local storage in multithreaded situations. - Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ - -/* This file contains thread-local storage primitives for use with a given - thread library. It does not contain primitives for creating threads or - for other multithreading primitives. - - Type: gl_tls_key_t - Initialization: gl_tls_key_init (name, destructor); - Getting per-thread value: gl_tls_get (name) - Setting per-thread value: gl_tls_set (name, pointer); - De-initialization: gl_tls_key_destroy (name); - Equivalent functions with control of error handling: - Initialization: err = glthread_tls_key_init (&name, destructor); - Setting per-thread value: err = glthread_tls_set (&name, pointer); - De-initialization: err = glthread_tls_key_destroy (&name); - - A per-thread value is of type 'void *'. - - A destructor is a function pointer of type 'void (*) (void *)', called - when a thread exits, and taking the last per-thread value as argument. It - is unspecified whether the destructor function is called when the last - per-thread value is NULL. On some platforms, the destructor function is - not called at all. -*/ - - -#ifndef _TLS_H -#define _TLS_H - -#include <errno.h> -#include <stdlib.h> - -/* ========================================================================= */ - -#if USE_POSIX_THREADS - -/* Use the POSIX threads library. */ - -# include <pthread.h> - -# if PTHREAD_IN_USE_DETECTION_HARD - -/* The pthread_in_use() detection needs to be done at runtime. */ -# define pthread_in_use() \ - glthread_in_use () -extern int glthread_in_use (void); - -# endif - -# if USE_POSIX_THREADS_WEAK - -/* Use weak references to the POSIX threads library. */ - -# pragma weak pthread_key_create -# pragma weak pthread_getspecific -# pragma weak pthread_setspecific -# pragma weak pthread_key_delete -# ifndef pthread_self -# pragma weak pthread_self -# endif - -# if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) -# endif - -# else - -# if !PTHREAD_IN_USE_DETECTION_HARD -# define pthread_in_use() 1 -# endif - -# endif - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef union - { - void *singlethread_value; - pthread_key_t key; - } - gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - (pthread_in_use () \ - ? pthread_key_create (&(KEY)->key, DESTRUCTOR) \ - : ((KEY)->singlethread_value = NULL, 0)) -# define gl_tls_get(NAME) \ - (pthread_in_use () \ - ? pthread_getspecific ((NAME).key) \ - : (NAME).singlethread_value) -# define glthread_tls_set(KEY, POINTER) \ - (pthread_in_use () \ - ? pthread_setspecific ((KEY)->key, (POINTER)) \ - : ((KEY)->singlethread_value = (POINTER), 0)) -# define glthread_tls_key_destroy(KEY) \ - (pthread_in_use () ? pthread_key_delete ((KEY)->key) : 0) - -#endif - -/* ========================================================================= */ - -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_key_create -# pragma weak pth_key_getdata -# pragma weak pth_key_setdata -# pragma weak pth_key_delete - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL) - -# else - -# define pth_in_use() 1 - -# endif - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef union - { - void *singlethread_value; - pth_key_t key; - } - gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - (pth_in_use () \ - ? (!pth_key_create (&(KEY)->key, DESTRUCTOR) ? errno : 0) \ - : ((KEY)->singlethread_value = NULL, 0)) -# define gl_tls_get(NAME) \ - (pth_in_use () \ - ? pth_key_getdata ((NAME).key) \ - : (NAME).singlethread_value) -# define glthread_tls_set(KEY, POINTER) \ - (pth_in_use () \ - ? (!pth_key_setdata ((KEY)->key, (POINTER)) ? errno : 0) \ - : ((KEY)->singlethread_value = (POINTER), 0)) -# define glthread_tls_key_destroy(KEY) \ - (pth_in_use () \ - ? (!pth_key_delete ((KEY)->key) ? errno : 0) \ - : 0) - -#endif - -/* ========================================================================= */ - -#if USE_SOLARIS_THREADS - -/* Use the old Solaris threads library. */ - -# include <thread.h> - -# if USE_SOLARIS_THREADS_WEAK - -/* Use weak references to the old Solaris threads library. */ - -# pragma weak thr_keycreate -# pragma weak thr_getspecific -# pragma weak thr_setspecific - -# pragma weak thr_suspend -# define thread_in_use() (thr_suspend != NULL) - -# else - -# define thread_in_use() 1 - -# endif - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef union - { - void *singlethread_value; - thread_key_t key; - } - gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - (thread_in_use () \ - ? thr_keycreate (&(KEY)->key, DESTRUCTOR) \ - : ((KEY)->singlethread_value = NULL, 0)) -# define gl_tls_get(NAME) \ - (thread_in_use () \ - ? glthread_tls_get_multithreaded ((NAME).key) \ - : (NAME).singlethread_value) -extern void *glthread_tls_get_multithreaded (thread_key_t key); -# define glthread_tls_set(KEY, POINTER) \ - (thread_in_use () \ - ? thr_setspecific ((KEY)->key, (POINTER)) \ - : ((KEY)->singlethread_value = (POINTER), 0)) -# define glthread_tls_key_destroy(KEY) \ - /* Unsupported. */ \ - 0 - -#endif - -/* ========================================================================= */ - -#if USE_WINDOWS_THREADS - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef DWORD gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - /* The destructor is unsupported. */ \ - ((*(KEY) = TlsAlloc ()) == (DWORD)-1 ? EAGAIN : ((void) (DESTRUCTOR), 0)) -# define gl_tls_get(NAME) \ - TlsGetValue (NAME) -# define glthread_tls_set(KEY, POINTER) \ - (!TlsSetValue (*(KEY), POINTER) ? EINVAL : 0) -# define glthread_tls_key_destroy(KEY) \ - (!TlsFree (*(KEY)) ? EINVAL : 0) - -#endif - -/* ========================================================================= */ - -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) - -/* Provide dummy implementation if threads are not supported. */ - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef struct - { - void *singlethread_value; - } - gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - ((KEY)->singlethread_value = NULL, \ - (void) (DESTRUCTOR), \ - 0) -# define gl_tls_get(NAME) \ - (NAME).singlethread_value -# define glthread_tls_set(KEY, POINTER) \ - ((KEY)->singlethread_value = (POINTER), 0) -# define glthread_tls_key_destroy(KEY) \ - 0 - -#endif - -/* ========================================================================= */ - -/* Macros with built-in error handling. */ - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -#define gl_tls_key_init(NAME, DESTRUCTOR) \ - do \ - { \ - if (glthread_tls_key_init (&NAME, DESTRUCTOR)) \ - abort (); \ - } \ - while (0) -#define gl_tls_set(NAME, POINTER) \ - do \ - { \ - if (glthread_tls_set (&NAME, POINTER)) \ - abort (); \ - } \ - while (0) -#define gl_tls_key_destroy(NAME) \ - do \ - { \ - if (glthread_tls_key_destroy (&NAME)) \ - abort (); \ - } \ - while (0) - -/* ========================================================================= */ - -#endif /* _TLS_H */ diff --git a/contrib/tools/bison/lib/itold.c b/contrib/tools/bison/lib/itold.c deleted file mode 100644 index 9aabc7e464..0000000000 --- a/contrib/tools/bison/lib/itold.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2011. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <float.h> - -void -_Qp_itoq (long double *result, int a) -{ - /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ - *result = (double) a; -} diff --git a/contrib/tools/bison/lib/localeconv.c b/contrib/tools/bison/lib/localeconv.c deleted file mode 100644 index 7c7c77cfd4..0000000000 --- a/contrib/tools/bison/lib/localeconv.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Query locale dependent information for formatting numbers. - Copyright (C) 2012-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <locale.h> - -#if HAVE_STRUCT_LCONV_DECIMAL_POINT - -/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* - members. */ - -struct lconv * -localeconv (void) -{ - static struct lconv result; -# undef lconv -# undef localeconv - struct lconv *sys_result = localeconv (); - - result.decimal_point = sys_result->decimal_point; - result.thousands_sep = sys_result->thousands_sep; - result.grouping = sys_result->grouping; - result.mon_decimal_point = sys_result->mon_decimal_point; - result.mon_thousands_sep = sys_result->mon_thousands_sep; - result.mon_grouping = sys_result->mon_grouping; - result.positive_sign = sys_result->positive_sign; - result.negative_sign = sys_result->negative_sign; - result.currency_symbol = sys_result->currency_symbol; - result.frac_digits = sys_result->frac_digits; - result.p_cs_precedes = sys_result->p_cs_precedes; - result.p_sign_posn = sys_result->p_sign_posn; - result.p_sep_by_space = sys_result->p_sep_by_space; - result.n_cs_precedes = sys_result->n_cs_precedes; - result.n_sign_posn = sys_result->n_sign_posn; - result.n_sep_by_space = sys_result->n_sep_by_space; - result.int_curr_symbol = sys_result->int_curr_symbol; - result.int_frac_digits = sys_result->int_frac_digits; - result.int_p_cs_precedes = sys_result->p_cs_precedes; - result.int_p_sign_posn = sys_result->p_sign_posn; - result.int_p_sep_by_space = sys_result->p_sep_by_space; - result.int_n_cs_precedes = sys_result->n_cs_precedes; - result.int_n_sign_posn = sys_result->n_sign_posn; - result.int_n_sep_by_space = sys_result->n_sep_by_space; - - return &result; -} - -#else - -/* Override for platforms where 'struct lconv' is a dummy. */ - -# include <limits.h> - -struct lconv * -localeconv (void) -{ - static /*const*/ struct lconv result = - { - /* decimal_point */ ".", - /* thousands_sep */ "", - /* grouping */ "", - /* mon_decimal_point */ "", - /* mon_thousands_sep */ "", - /* mon_grouping */ "", - /* positive_sign */ "", - /* negative_sign */ "", - /* currency_symbol */ "", - /* frac_digits */ CHAR_MAX, - /* p_cs_precedes */ CHAR_MAX, - /* p_sign_posn */ CHAR_MAX, - /* p_sep_by_space */ CHAR_MAX, - /* n_cs_precedes */ CHAR_MAX, - /* n_sign_posn */ CHAR_MAX, - /* n_sep_by_space */ CHAR_MAX, - /* int_curr_symbol */ "", - /* int_frac_digits */ CHAR_MAX, - /* int_p_cs_precedes */ CHAR_MAX, - /* int_p_sign_posn */ CHAR_MAX, - /* int_p_sep_by_space */ CHAR_MAX, - /* int_n_cs_precedes */ CHAR_MAX, - /* int_n_sign_posn */ CHAR_MAX, - /* int_n_sep_by_space */ CHAR_MAX - }; - - return &result; -} - -#endif diff --git a/contrib/tools/bison/lib/lseek.c b/contrib/tools/bison/lib/lseek.c deleted file mode 100644 index fa7440d151..0000000000 --- a/contrib/tools/bison/lib/lseek.c +++ /dev/null @@ -1,67 +0,0 @@ -/* An lseek() function that detects pipes. - Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <unistd.h> - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* Windows platforms. */ -/* Get GetFileType. */ -# include <windows.h> -/* Get _get_osfhandle. */ -# include "msvc-nothrow.h" -#else -# include <sys/stat.h> -#endif -#include <errno.h> - -#undef lseek - -off_t -rpl_lseek (int fd, off_t offset, int whence) -{ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */ - HANDLE h = (HANDLE) _get_osfhandle (fd); - if (h == INVALID_HANDLE_VALUE) - { - errno = EBADF; - return -1; - } - if (GetFileType (h) != FILE_TYPE_DISK) - { - errno = ESPIPE; - return -1; - } -#else - /* BeOS lseek mistakenly succeeds on pipes... */ - struct stat statbuf; - if (fstat (fd, &statbuf) < 0) - return -1; - if (!S_ISREG (statbuf.st_mode)) - { - errno = ESPIPE; - return -1; - } -#endif -#if _GL_WINDOWS_64_BIT_OFF_T - return _lseeki64 (fd, offset, whence); -#else - return lseek (fd, offset, whence); -#endif -} diff --git a/contrib/tools/bison/lib/lstat.c b/contrib/tools/bison/lib/lstat.c deleted file mode 100644 index 1a613a89c8..0000000000 --- a/contrib/tools/bison/lib/lstat.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Work around a bug of lstat on some systems - - Copyright (C) 1997-2006, 2008-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* written by Jim Meyering */ - -/* If the user's config.h happens to include <sys/stat.h>, let it include only - the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to - rpl_lstat. */ -#define __need_system_sys_stat_h -#include <config.h> - -#if !HAVE_LSTAT -/* On systems that lack symlinks, our replacement <sys/stat.h> already - defined lstat as stat, so there is nothing further to do other than - avoid an empty file. */ -typedef int dummy; -#else /* HAVE_LSTAT */ - -/* Get the original definition of lstat. It might be defined as a macro. */ -# include <sys/types.h> -# include <sys/stat.h> -# undef __need_system_sys_stat_h - -static int -orig_lstat (const char *filename, struct stat *buf) -{ - return lstat (filename, buf); -} - -/* Specification. */ -/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc - eliminates this include because of the preliminary #include <sys/stat.h> - above. */ -# include "sys/stat.h" - -# include <string.h> -# include <errno.h> - -/* lstat works differently on Linux and Solaris systems. POSIX (see - "pathname resolution" in the glossary) requires that programs like - 'ls' take into consideration the fact that FILE has a trailing slash - when FILE is a symbolic link. On Linux and Solaris 10 systems, the - lstat function already has the desired semantics (in treating - 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)', - but on Solaris 9 and earlier it does not. - - If FILE has a trailing slash and specifies a symbolic link, - then use stat() to get more info on the referent of FILE. - If the referent is a non-directory, then set errno to ENOTDIR - and return -1. Otherwise, return stat's result. */ - -int -rpl_lstat (const char *file, struct stat *sbuf) -{ - size_t len; - int lstat_result = orig_lstat (file, sbuf); - - if (lstat_result != 0) - return lstat_result; - - /* This replacement file can blindly check against '/' rather than - using the ISSLASH macro, because all platforms with '\\' either - lack symlinks (mingw) or have working lstat (cygwin) and thus do - not compile this file. 0 len should have already been filtered - out above, with a failure return of ENOENT. */ - len = strlen (file); - if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode)) - return 0; - - /* At this point, a trailing slash is only permitted on - symlink-to-dir; but it should have found information on the - directory, not the symlink. Call stat() to get info about the - link's referent. Our replacement stat guarantees valid results, - even if the symlink is not pointing to a directory. */ - if (!S_ISLNK (sbuf->st_mode)) - { - errno = ENOTDIR; - return -1; - } - return stat (file, sbuf); -} - -#endif /* HAVE_LSTAT */ diff --git a/contrib/tools/bison/lib/malloca.h b/contrib/tools/bison/lib/malloca.h index 8ec4465dc7..6fbe45eab6 100644 --- a/contrib/tools/bison/lib/malloca.h +++ b/contrib/tools/bison/lib/malloca.h @@ -18,7 +18,7 @@ #ifndef _MALLOCA_H #define _MALLOCA_H -#include "palloca.h" +#include <alloca.h> #include <stddef.h> #include <stdlib.h> diff --git a/contrib/tools/bison/lib/mkdtemp.c b/contrib/tools/bison/lib/mkdtemp.c deleted file mode 100644 index 6ba8b65d52..0000000000 --- a/contrib/tools/bison/lib/mkdtemp.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1999, 2001-2003, 2006-2007, 2009-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Extracted from misc/mkdtemp.c. */ - -#include <config.h> - -/* Specification. */ -#include <stdlib.h> - -#include "tempname.h" - -/* Generate a unique temporary directory from XTEMPLATE. - The last six characters of XTEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the filename unique. - The directory is created, mode 700, and its name is returned. - (This function comes from OpenBSD.) */ -char * -mkdtemp (char *xtemplate) -{ - if (gen_tempname (xtemplate, 0, 0, GT_DIR)) - return NULL; - else - return xtemplate; -} diff --git a/contrib/tools/bison/lib/mkstemp-safer.c b/contrib/tools/bison/lib/mkstemp-safer.c deleted file mode 100644 index 9ddf86fb60..0000000000 --- a/contrib/tools/bison/lib/mkstemp-safer.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Invoke mkstemp, but avoid some glitches. - - Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Paul Eggert. */ - -#include <config.h> - -#include "stdlib-safer.h" - -#include "stdlib--.h" -#include "unistd-safer.h" - - -/* Like mkstemp, but do not return STDIN_FILENO, STDOUT_FILENO, or - STDERR_FILENO. */ - -int -mkstemp_safer (char *templ) -{ - return fd_safer (mkstemp (templ)); -} - -#if GNULIB_MKOSTEMP -/* Like mkostemp, but do not return STDIN_FILENO, STDOUT_FILENO, or - STDERR_FILENO. */ -int -mkostemp_safer (char *templ, int flags) -{ - return fd_safer_flag (mkostemp (templ, flags), flags); -} -#endif - -#if GNULIB_MKOSTEMPS -/* Like mkostemps, but do not return STDIN_FILENO, STDOUT_FILENO, or - STDERR_FILENO. */ -int -mkostemps_safer (char *templ, int suffixlen, int flags) -{ - return fd_safer_flag (mkostemps (templ, suffixlen, flags), flags); -} -#endif - -#if GNULIB_MKSTEMPS -/* Like mkstemps, but do not return STDIN_FILENO, STDOUT_FILENO, or - STDERR_FILENO. */ -int mkstemps_safer (char *templ, int suffixlen) -{ - return fd_safer (mkstemps (templ, suffixlen)); -} -#endif diff --git a/contrib/tools/bison/lib/mkstemp.c b/contrib/tools/bison/lib/mkstemp.c deleted file mode 100644 index 7a9af6c8cc..0000000000 --- a/contrib/tools/bison/lib/mkstemp.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2013 Free Software - Foundation, Inc. - This file is derived from the one in the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#if !_LIBC -# include <config.h> -#endif - -#include <stdlib.h> - -#if !_LIBC -# include "tempname.h" -# define __gen_tempname gen_tempname -# ifndef __GT_FILE -# define __GT_FILE GT_FILE -# endif -#endif - -#include <stdio.h> - -#ifndef __GT_FILE -# define __GT_FILE 0 -#endif - -/* Generate a unique temporary file name from XTEMPLATE. - The last six characters of XTEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the file name unique. - Then open the file and return a fd. - - If you are creating temporary files which will later be removed, - consider using the clean-temp module, which avoids several pitfalls - of using mkstemp directly. */ -int -mkstemp (char *xtemplate) -{ - return __gen_tempname (xtemplate, 0, 0, __GT_FILE); -} diff --git a/contrib/tools/bison/lib/palloca.h b/contrib/tools/bison/lib/palloca.h deleted file mode 100644 index a7ed8a2f9c..0000000000 --- a/contrib/tools/bison/lib/palloca.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#if defined(__FreeBSD__) - #include <stdlib.h> -#else - #include <alloca.h> -#endif diff --git a/contrib/tools/bison/lib/pathmax.h b/contrib/tools/bison/lib/pathmax.h deleted file mode 100644 index a9ddc33d17..0000000000 --- a/contrib/tools/bison/lib/pathmax.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2013 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. */ - -#ifndef _PATHMAX_H -# define _PATHMAX_H - -/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, - including the terminating NUL byte. - <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html> - PATH_MAX is not defined on systems which have no limit on filename length, - such as GNU/Hurd. - - This file does *not* define PATH_MAX always. Programs that use this file - can handle the GNU/Hurd case in several ways: - - Either with a package-wide handling, or with a per-file handling, - - Either through a - #ifdef PATH_MAX - or through a fallback like - #ifndef PATH_MAX - # define PATH_MAX 8192 - #endif - or through a fallback like - #ifndef PATH_MAX - # define PATH_MAX pathconf ("/", _PC_PATH_MAX) - #endif - */ - -# include <unistd.h> - -# include <limits.h> - -# ifndef _POSIX_PATH_MAX -# define _POSIX_PATH_MAX 256 -# endif - -/* Don't include sys/param.h if it already has been. */ -# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN -# include <sys/param.h> -# endif - -# if !defined PATH_MAX && defined MAXPATHLEN -# define PATH_MAX MAXPATHLEN -# endif - -# ifdef __hpux -/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, - *not* including the terminating NUL byte, and is set to 1023. - Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is - not defined at all any more. */ -# undef PATH_MAX -# define PATH_MAX 1024 -# endif - -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, - section "Maximum Path Length Limitation", - <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath> - explains that the maximum size of a filename, including the terminating - NUL byte, is 260 = 3 + 256 + 1. - This is the same value as - - FILENAME_MAX in <stdio.h>, - - _MAX_PATH in <stdlib.h>, - - MAX_PATH in <windef.h>. - Undefine the original value, because mingw's <limits.h> gets it wrong. */ -# undef PATH_MAX -# define PATH_MAX 260 -# endif - -#endif /* _PATHMAX_H */ diff --git a/contrib/tools/bison/lib/perror.c b/contrib/tools/bison/lib/perror.c deleted file mode 100644 index 74e088cc73..0000000000 --- a/contrib/tools/bison/lib/perror.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Print a message describing error code. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - Written by Bruno Haible and Simon Josefsson. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -void -perror (const char *string) -{ - if (string != NULL && *string != '\0') - fprintf (stderr, "%s\n", string); -} diff --git a/contrib/tools/bison/lib/platform/win64/config.h b/contrib/tools/bison/lib/platform/win64/config.h index 7b03effd7b..a34046c4a9 100644 --- a/contrib/tools/bison/lib/platform/win64/config.h +++ b/contrib/tools/bison/lib/platform/win64/config.h @@ -1284,7 +1284,7 @@ char *strsignal (int signum); /* Define to 1 if stat needs help when passed a directory name with a trailing slash */ -#define REPLACE_FUNC_STAT_DIR 1 +// #define REPLACE_FUNC_STAT_DIR 1 /* Define to 1 if stat needs help when passed a file name with a trailing slash */ diff --git a/contrib/tools/bison/lib/rawmemchr.c b/contrib/tools/bison/lib/rawmemchr.c deleted file mode 100644 index a0298ce64e..0000000000 --- a/contrib/tools/bison/lib/rawmemchr.c +++ /dev/null @@ -1,136 +0,0 @@ -/* Searching in a string. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <string.h> - -/* Find the first occurrence of C in S. */ -void * -rawmemchr (const void *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (*char_ptr == c) - return (void *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 is zero. - - We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 is zero is equivalent - to testing whether tmp is nonzero. - - This test can read beyond the end of a string, depending on where - C_IN is encountered. However, this is considered safe since the - initialization phase ensured that the read will be aligned, - therefore, the read will not cross page boundaries and will not - cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - - if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == c. On little-endian machines, we - could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr != c) - char_ptr++; - return (void *) char_ptr; -} diff --git a/contrib/tools/bison/lib/readlink.c b/contrib/tools/bison/lib/readlink.c deleted file mode 100644 index f83a1e0123..0000000000 --- a/contrib/tools/bison/lib/readlink.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Stub for readlink(). - Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include <unistd.h> - -#include <errno.h> -#include <string.h> -#include <sys/stat.h> - -#if !HAVE_READLINK - -/* readlink() substitute for systems that don't have a readlink() function, - such as DJGPP 2.03 and mingw32. */ - -ssize_t -readlink (const char *name, char *buf _GL_UNUSED, - size_t bufsize _GL_UNUSED) -{ - struct stat statbuf; - - /* In general we should use lstat() here, not stat(). But on platforms - without symbolic links, lstat() - if it exists - would be equivalent to - stat(), therefore we can use stat(). This saves us a configure check. */ - if (stat (name, &statbuf) >= 0) - errno = EINVAL; - return -1; -} - -#else /* HAVE_READLINK */ - -# undef readlink - -/* readlink() wrapper that uses correct types, for systems like cygwin - 1.5.x where readlink returns int, and which rejects trailing slash, - for Solaris 9. */ - -ssize_t -rpl_readlink (const char *name, char *buf, size_t bufsize) -{ -# if READLINK_TRAILING_SLASH_BUG - size_t len = strlen (name); - if (len && name[len - 1] == '/') - { - /* Even if name without the slash is a symlink to a directory, - both lstat() and stat() must resolve the trailing slash to - the directory rather than the symlink. We can therefore - safely use stat() to distinguish between EINVAL and - ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ - struct stat st; - if (stat (name, &st) == 0) - errno = EINVAL; - return -1; - } -# endif /* READLINK_TRAILING_SLASH_BUG */ - return readlink (name, buf, bufsize); -} - -#endif /* HAVE_READLINK */ diff --git a/contrib/tools/bison/lib/rename.c b/contrib/tools/bison/lib/rename.c deleted file mode 100644 index 3e463ea86a..0000000000 --- a/contrib/tools/bison/lib/rename.c +++ /dev/null @@ -1,473 +0,0 @@ -/* Work around rename bugs in some systems. - - Copyright (C) 2001-2003, 2005-2006, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Volker Borchert, Eric Blake. */ - -#include <config.h> - -#include <stdio.h> - -#undef rename - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -/* The mingw rename has problems with trailing slashes; it also - requires use of native Windows calls to allow atomic renames over - existing files. */ - -# include <errno.h> -# include <stdbool.h> -# include <stdlib.h> -# include <sys/stat.h> -# include <unistd.h> - -# define WIN32_LEAN_AND_MEAN -# include <windows.h> - -# include "dirname.h" - -/* Rename the file SRC to DST. This replacement is necessary on - Windows, on which the system rename function will not replace - an existing DST. */ -int -rpl_rename (char const *src, char const *dst) -{ - int error; - size_t src_len = strlen (src); - size_t dst_len = strlen (dst); - char *src_base = last_component (src); - char *dst_base = last_component (dst); - bool src_slash; - bool dst_slash; - bool dst_exists; - struct stat src_st; - struct stat dst_st; - - /* Filter out dot as last component. */ - if (!src_len || !dst_len) - { - errno = ENOENT; - return -1; - } - if (*src_base == '.') - { - size_t len = base_len (src_base); - if (len == 1 || (len == 2 && src_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - if (*dst_base == '.') - { - size_t len = base_len (dst_base); - if (len == 1 || (len == 2 && dst_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - - /* Presence of a trailing slash requires directory semantics. If - the source does not exist, or if the destination cannot be turned - into a directory, give up now. Otherwise, strip trailing slashes - before calling rename. There are no symlinks on mingw, so stat - works instead of lstat. */ - src_slash = ISSLASH (src[src_len - 1]); - dst_slash = ISSLASH (dst[dst_len - 1]); - if (stat (src, &src_st)) - return -1; - if (stat (dst, &dst_st)) - { - if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) - return -1; - dst_exists = false; - } - else - { - if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) - { - errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; - return -1; - } - dst_exists = true; - } - - /* There are no symlinks, so if a file existed with a trailing - slash, it must be a directory, and we don't have to worry about - stripping strip trailing slash. However, mingw refuses to - replace an existing empty directory, so we have to help it out. - And canonicalize_file_name is not yet ported to mingw; however, - for directories, getcwd works as a viable alternative. Ensure - that we can get back to where we started before using it; later - attempts to return are fatal. Note that we can end up losing a - directory if rename then fails, but it was empty, so not much - damage was done. */ - if (dst_exists && S_ISDIR (dst_st.st_mode)) - { - char *cwd = getcwd (NULL, 0); - char *src_temp; - char *dst_temp; - if (!cwd || chdir (cwd)) - return -1; - if (IS_ABSOLUTE_FILE_NAME (src)) - { - dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); - src_temp = chdir (src) ? NULL : getcwd (NULL, 0); - } - else - { - src_temp = chdir (src) ? NULL : getcwd (NULL, 0); - if (!IS_ABSOLUTE_FILE_NAME (dst) && chdir (cwd)) - abort (); - dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); - } - if (chdir (cwd)) - abort (); - free (cwd); - if (!src_temp || !dst_temp) - { - free (src_temp); - free (dst_temp); - errno = ENOMEM; - return -1; - } - src_len = strlen (src_temp); - if (strncmp (src_temp, dst_temp, src_len) == 0 - && (ISSLASH (dst_temp[src_len]) || dst_temp[src_len] == '\0')) - { - error = dst_temp[src_len]; - free (src_temp); - free (dst_temp); - if (error) - { - errno = EINVAL; - return -1; - } - return 0; - } - if (rmdir (dst)) - { - error = errno; - free (src_temp); - free (dst_temp); - errno = error; - return -1; - } - free (src_temp); - free (dst_temp); - } - - /* MoveFileEx works if SRC is a directory without any flags, but - fails with MOVEFILE_REPLACE_EXISTING, so try without flags first. - Thankfully, MoveFileEx handles hard links correctly, even though - rename() does not. */ - if (MoveFileEx (src, dst, 0)) - return 0; - - /* Retry with MOVEFILE_REPLACE_EXISTING if the move failed - due to the destination already existing. */ - error = GetLastError (); - if (error == ERROR_FILE_EXISTS || error == ERROR_ALREADY_EXISTS) - { - if (MoveFileEx (src, dst, MOVEFILE_REPLACE_EXISTING)) - return 0; - - error = GetLastError (); - } - - switch (error) - { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - case ERROR_BAD_PATHNAME: - case ERROR_DIRECTORY: - errno = ENOENT; - break; - - case ERROR_ACCESS_DENIED: - case ERROR_SHARING_VIOLATION: - errno = EACCES; - break; - - case ERROR_OUTOFMEMORY: - errno = ENOMEM; - break; - - case ERROR_CURRENT_DIRECTORY: - errno = EBUSY; - break; - - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; - break; - - case ERROR_WRITE_PROTECT: - errno = EROFS; - break; - - case ERROR_WRITE_FAULT: - case ERROR_READ_FAULT: - case ERROR_GEN_FAILURE: - errno = EIO; - break; - - case ERROR_HANDLE_DISK_FULL: - case ERROR_DISK_FULL: - case ERROR_DISK_TOO_FRAGMENTED: - errno = ENOSPC; - break; - - case ERROR_FILE_EXISTS: - case ERROR_ALREADY_EXISTS: - errno = EEXIST; - break; - - case ERROR_BUFFER_OVERFLOW: - case ERROR_FILENAME_EXCED_RANGE: - errno = ENAMETOOLONG; - break; - - case ERROR_INVALID_NAME: - case ERROR_DELETE_PENDING: - errno = EPERM; /* ? */ - break; - -# ifndef ERROR_FILE_TOO_LARGE -/* This value is documented but not defined in all versions of windows.h. */ -# define ERROR_FILE_TOO_LARGE 223 -# endif - case ERROR_FILE_TOO_LARGE: - errno = EFBIG; - break; - - default: - errno = EINVAL; - break; - } - - return -1; -} - -#else /* ! W32 platform */ - -# include <errno.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -# include <sys/stat.h> -# include <unistd.h> - -# include "dirname.h" -# include "same-inode.h" - -/* Rename the file SRC to DST, fixing any trailing slash bugs. */ - -int -rpl_rename (char const *src, char const *dst) -{ - size_t src_len = strlen (src); - size_t dst_len = strlen (dst); - char *src_temp = (char *) src; - char *dst_temp = (char *) dst; - bool src_slash; - bool dst_slash; - bool dst_exists; - int ret_val = -1; - int rename_errno = ENOTDIR; - struct stat src_st; - struct stat dst_st; - - if (!src_len || !dst_len) - return rename (src, dst); /* Let strace see the ENOENT failure. */ - -# if RENAME_DEST_EXISTS_BUG - { - char *src_base = last_component (src); - char *dst_base = last_component (dst); - if (*src_base == '.') - { - size_t len = base_len (src_base); - if (len == 1 || (len == 2 && src_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - if (*dst_base == '.') - { - size_t len = base_len (dst_base); - if (len == 1 || (len == 2 && dst_base[1] == '.')) - { - errno = EINVAL; - return -1; - } - } - } -# endif /* RENAME_DEST_EXISTS_BUG */ - - src_slash = src[src_len - 1] == '/'; - dst_slash = dst[dst_len - 1] == '/'; - -# if !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG - /* If there are no trailing slashes, then trust the native - implementation unless we also suspect issues with hard link - detection or file/directory conflicts. */ - if (!src_slash && !dst_slash) - return rename (src, dst); -# endif /* !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG */ - - /* Presence of a trailing slash requires directory semantics. If - the source does not exist, or if the destination cannot be turned - into a directory, give up now. Otherwise, strip trailing slashes - before calling rename. */ - if (lstat (src, &src_st)) - return -1; - if (lstat (dst, &dst_st)) - { - if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) - return -1; - dst_exists = false; - } - else - { - if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) - { - errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; - return -1; - } -# if RENAME_HARD_LINK_BUG - if (SAME_INODE (src_st, dst_st)) - return 0; -# endif /* RENAME_HARD_LINK_BUG */ - dst_exists = true; - } - -# if (RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG \ - || RENAME_HARD_LINK_BUG) - /* If the only bug was that a trailing slash was allowed on a - non-existing file destination, as in Solaris 10, then we've - already covered that situation. But if there is any problem with - a trailing slash on an existing source or destination, as in - Solaris 9, or if a directory can overwrite a symlink, as on - Cygwin 1.5, or if directories cannot be created with trailing - slash, as on NetBSD 1.6, then we must strip the offending slash - and check that we have not encountered a symlink instead of a - directory. - - Stripping a trailing slash interferes with POSIX semantics, where - rename behavior on a symlink with a trailing slash operates on - the corresponding target directory. We prefer the GNU semantics - of rejecting any use of a symlink with trailing slash, but do not - enforce them, since Solaris 10 is able to obey POSIX semantics - and there might be clients expecting it, as counter-intuitive as - those semantics are. - - Technically, we could also follow the POSIX behavior by chasing a - readlink trail, but that is harder to implement. */ - if (src_slash) - { - src_temp = strdup (src); - if (!src_temp) - { - /* Rather than rely on strdup-posix, we set errno ourselves. */ - rename_errno = ENOMEM; - goto out; - } - strip_trailing_slashes (src_temp); - if (lstat (src_temp, &src_st)) - { - rename_errno = errno; - goto out; - } - if (S_ISLNK (src_st.st_mode)) - goto out; - } - if (dst_slash) - { - dst_temp = strdup (dst); - if (!dst_temp) - { - rename_errno = ENOMEM; - goto out; - } - strip_trailing_slashes (dst_temp); - if (lstat (dst_temp, &dst_st)) - { - if (errno != ENOENT) - { - rename_errno = errno; - goto out; - } - } - else if (S_ISLNK (dst_st.st_mode)) - goto out; - } -# endif /* RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG - || RENAME_HARD_LINK_BUG */ - -# if RENAME_DEST_EXISTS_BUG - /* Cygwin 1.5 sometimes behaves oddly when moving a non-empty - directory on top of an empty one (the old directory name can - reappear if the new directory tree is removed). Work around this - by removing the target first, but don't remove the target if it - is a subdirectory of the source. Note that we can end up losing - a directory if rename then fails, but it was empty, so not much - damage was done. */ - if (dst_exists && S_ISDIR (dst_st.st_mode)) - { - if (src_st.st_dev != dst_st.st_dev) - { - rename_errno = EXDEV; - goto out; - } - if (src_temp != src) - free (src_temp); - src_temp = canonicalize_file_name (src); - if (dst_temp != dst) - free (dst_temp); - dst_temp = canonicalize_file_name (dst); - if (!src_temp || !dst_temp) - { - rename_errno = ENOMEM; - goto out; - } - src_len = strlen (src_temp); - if (strncmp (src_temp, dst_temp, src_len) == 0 - && dst_temp[src_len] == '/') - { - rename_errno = EINVAL; - goto out; - } - if (rmdir (dst)) - { - rename_errno = errno; - goto out; - } - } -# endif /* RENAME_DEST_EXISTS_BUG */ - - ret_val = rename (src_temp, dst_temp); - rename_errno = errno; - out: - if (src_temp != src) - free (src_temp); - if (dst_temp != dst) - free (dst_temp); - errno = rename_errno; - return ret_val; -} -#endif /* ! W32 platform */ diff --git a/contrib/tools/bison/lib/rmdir.c b/contrib/tools/bison/lib/rmdir.c deleted file mode 100644 index a8d907ebf0..0000000000 --- a/contrib/tools/bison/lib/rmdir.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Work around rmdir bugs. - - Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2013 Free Software - Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -#include <unistd.h> - -#include <errno.h> -#include <string.h> - -#include "dosname.h" - -#undef rmdir - -/* Remove directory DIR. - Return 0 if successful, -1 if not. */ - -int -rpl_rmdir (char const *dir) -{ - /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */ - size_t len = strlen (dir); - int result; - while (len && ISSLASH (dir[len - 1])) - len--; - if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2]))) - { - errno = EINVAL; - return -1; - } - result = rmdir (dir); - /* Work around mingw bug, where rmdir("file/") fails with EINVAL - instead of ENOTDIR. We've already filtered out trailing ., the - only reason allowed by POSIX for EINVAL. */ - if (result == -1 && errno == EINVAL) - errno = ENOTDIR; - return result; -} diff --git a/contrib/tools/bison/lib/same-inode.h b/contrib/tools/bison/lib/same-inode.h deleted file mode 100644 index 3843b07078..0000000000 --- a/contrib/tools/bison/lib/same-inode.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Determine whether two stat buffers refer to the same file. - - Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef SAME_INODE_H -# define SAME_INODE_H 1 - -# ifdef __VMS -# define SAME_INODE(a, b) \ - ((a).st_ino[0] == (b).st_ino[0] \ - && (a).st_ino[1] == (b).st_ino[1] \ - && (a).st_ino[2] == (b).st_ino[2] \ - && (a).st_dev == (b).st_dev) -# else -# define SAME_INODE(a, b) \ - ((a).st_ino == (b).st_ino \ - && (a).st_dev == (b).st_dev) -# endif - -#endif diff --git a/contrib/tools/bison/lib/secure_getenv.c b/contrib/tools/bison/lib/secure_getenv.c deleted file mode 100644 index 6c11c5e0ed..0000000000 --- a/contrib/tools/bison/lib/secure_getenv.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Look up an environment variable more securely. - - Copyright 2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -#include <stdlib.h> - -#if !HAVE___SECURE_GETENV -# if HAVE_ISSETUGID -# include <unistd.h> -# else -# undef issetugid -# define issetugid() 1 -# endif -#endif - -char * -secure_getenv (char const *name) -{ -#if HAVE___SECURE_GETENV - return __secure_getenv (name); -#else - if (issetugid ()) - return 0; - return getenv (name); -#endif -} diff --git a/contrib/tools/bison/lib/siglist.h b/contrib/tools/bison/lib/siglist.h deleted file mode 100644 index 7817c95b31..0000000000 --- a/contrib/tools/bison/lib/siglist.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Canonical list of all signal names. - Copyright (C) 1996-1999, 2008-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* This file should be usable for any platform, since it just associates - the SIG* macros with text names and descriptions. The actual values - come from <bits/signum.h> (via <signal.h>). For any signal macros do not - exist on every platform, we can use #ifdef tests here and still use - this single common file for all platforms. */ - -/* This file is included multiple times. */ - -/* Duplicate values (such as SIGBUS==SIGSEGV on Haiku) favor the last - list entry. */ - -/* Standard signals */ -#ifdef SIGHUP - init_sig (SIGHUP, "HUP", N_("Hangup")) -#endif -#ifdef SIGINT - init_sig (SIGINT, "INT", N_("Interrupt")) -#endif -#ifdef SIGQUIT - init_sig (SIGQUIT, "QUIT", N_("Quit")) -#endif -#ifdef SIGILL - init_sig (SIGILL, "ILL", N_("Illegal instruction")) -#endif -#ifdef SIGTRAP - init_sig (SIGTRAP, "TRAP", N_("Trace/breakpoint trap")) -#endif -#ifdef SIGABRT - init_sig (SIGABRT, "ABRT", N_("Aborted")) -#endif -#ifdef SIGFPE - init_sig (SIGFPE, "FPE", N_("Floating point exception")) -#endif -#ifdef SIGKILL - init_sig (SIGKILL, "KILL", N_("Killed")) -#endif -#ifdef SIGBUS - init_sig (SIGBUS, "BUS", N_("Bus error")) -#endif -#ifdef SIGSEGV - init_sig (SIGSEGV, "SEGV", N_("Segmentation fault")) -#endif -#ifdef SIGPIPE - init_sig (SIGPIPE, "PIPE", N_("Broken pipe")) -#endif -#ifdef SIGALRM - init_sig (SIGALRM, "ALRM", N_("Alarm clock")) -#endif -#ifdef SIGTERM - init_sig (SIGTERM, "TERM", N_("Terminated")) -#endif -#ifdef SIGURG - init_sig (SIGURG, "URG", N_("Urgent I/O condition")) -#endif -#ifdef SIGSTOP - init_sig (SIGSTOP, "STOP", N_("Stopped (signal)")) -#endif -#ifdef SIGTSTP - init_sig (SIGTSTP, "TSTP", N_("Stopped")) -#endif -#ifdef SIGCONT - init_sig (SIGCONT, "CONT", N_("Continued")) -#endif -#ifdef SIGCHLD - init_sig (SIGCHLD, "CHLD", N_("Child exited")) -#endif -#ifdef SIGTTIN - init_sig (SIGTTIN, "TTIN", N_("Stopped (tty input)")) -#endif -#ifdef SIGTTOU - init_sig (SIGTTOU, "TTOU", N_("Stopped (tty output)")) -#endif -#ifdef SIGIO - init_sig (SIGIO, "IO", N_("I/O possible")) -#endif -#ifdef SIGXCPU - init_sig (SIGXCPU, "XCPU", N_("CPU time limit exceeded")) -#endif -#ifdef SIGXFSZ - init_sig (SIGXFSZ, "XFSZ", N_("File size limit exceeded")) -#endif -#ifdef SIGVTALRM - init_sig (SIGVTALRM, "VTALRM", N_("Virtual timer expired")) -#endif -#ifdef SIGPROF - init_sig (SIGPROF, "PROF", N_("Profiling timer expired")) -#endif -#ifdef SIGWINCH - init_sig (SIGWINCH, "WINCH", N_("Window changed")) -#endif -#ifdef SIGUSR1 - init_sig (SIGUSR1, "USR1", N_("User defined signal 1")) -#endif -#ifdef SIGUSR2 - init_sig (SIGUSR2, "USR2", N_("User defined signal 2")) -#endif - -/* Variations */ -#ifdef SIGEMT - init_sig (SIGEMT, "EMT", N_("EMT trap")) -#endif -#ifdef SIGSYS - init_sig (SIGSYS, "SYS", N_("Bad system call")) -#endif -#ifdef SIGSTKFLT - init_sig (SIGSTKFLT, "STKFLT", N_("Stack fault")) -#endif -#ifdef SIGINFO - init_sig (SIGINFO, "INFO", N_("Information request")) -#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR != SIGLOST)) - init_sig (SIGPWR, "PWR", N_("Power failure")) -#endif -#ifdef SIGLOST - init_sig (SIGLOST, "LOST", N_("Resource lost")) -#endif diff --git a/contrib/tools/bison/lib/stat.c b/contrib/tools/bison/lib/stat.c deleted file mode 100644 index f888130d26..0000000000 --- a/contrib/tools/bison/lib/stat.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Work around platform bugs in stat. - Copyright (C) 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* written by Eric Blake */ - -/* If the user's config.h happens to include <sys/stat.h>, let it include only - the system's <sys/stat.h> here, so that orig_stat doesn't recurse to - rpl_stat. */ -#define __need_system_sys_stat_h -#include <config.h> - -/* Get the original definition of stat. It might be defined as a macro. */ -#include <sys/types.h> -#include <sys/stat.h> -#undef __need_system_sys_stat_h - -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -# if _GL_WINDOWS_64_BIT_ST_SIZE -# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ -# define stat _stati64 -# define REPLACE_FUNC_STAT_DIR 1 -# undef REPLACE_FUNC_STAT_FILE -# elif REPLACE_FUNC_STAT_FILE -/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. - Bypass it. */ -# define stat _stat -# define REPLACE_FUNC_STAT_DIR 1 -# undef REPLACE_FUNC_STAT_FILE -# endif -#endif - -static int -orig_stat (const char *filename, struct stat *buf) -{ - return stat (filename, buf); -} - -/* Specification. */ -/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc - eliminates this include because of the preliminary #include <sys/stat.h> - above. */ -#include "sys/stat.h" - -#include <errno.h> -#include <limits.h> -#include <stdbool.h> -#include <string.h> -#include "dosname.h" -#include "verify.h" - -#if REPLACE_FUNC_STAT_DIR -# include "pathmax.h" - /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also - have a constant PATH_MAX. */ -# ifndef PATH_MAX -# error "Please port this replacement to your platform" -# endif -#endif - -/* Store information about NAME into ST. Work around bugs with - trailing slashes. Mingw has other bugs (such as st_ino always - being 0 on success) which this wrapper does not work around. But - at least this implementation provides the ability to emulate fchdir - correctly. */ - -int -rpl_stat (char const *name, struct stat *st) -{ - int result = orig_stat (name, st); -#if REPLACE_FUNC_STAT_FILE - /* Solaris 9 mistakenly succeeds when given a non-directory with a - trailing slash. */ - if (result == 0 && !S_ISDIR (st->st_mode)) - { - size_t len = strlen (name); - if (ISSLASH (name[len - 1])) - { - errno = ENOTDIR; - return -1; - } - } -#endif /* REPLACE_FUNC_STAT_FILE */ -#if REPLACE_FUNC_STAT_DIR - - if (result == -1 && errno == ENOENT) - { - /* Due to mingw's oddities, there are some directories (like - c:\) where stat() only succeeds with a trailing slash, and - other directories (like c:\windows) where stat() only - succeeds without a trailing slash. But we want the two to be - synonymous, since chdir() manages either style. Likewise, Mingw also - reports ENOENT for names longer than PATH_MAX, when we want - ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. - Fortunately, mingw PATH_MAX is small enough for stack - allocation. */ - char fixed_name[PATH_MAX + 1] = {0}; - size_t len = strlen (name); - bool check_dir = false; - verify (PATH_MAX <= 4096); - if (PATH_MAX <= len) - errno = ENAMETOOLONG; - else if (len) - { - strcpy (fixed_name, name); - if (ISSLASH (fixed_name[len - 1])) - { - check_dir = true; - while (len && ISSLASH (fixed_name[len - 1])) - fixed_name[--len] = '\0'; - if (!len) - fixed_name[0] = '/'; - } - else - fixed_name[len++] = '/'; - result = orig_stat (fixed_name, st); - if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) - { - result = -1; - errno = ENOTDIR; - } - } - } -#endif /* REPLACE_FUNC_STAT_DIR */ - return result; -} diff --git a/contrib/tools/bison/lib/stdlib--.h b/contrib/tools/bison/lib/stdlib--.h deleted file mode 100644 index 28360a2707..0000000000 --- a/contrib/tools/bison/lib/stdlib--.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Like stdlib.h, but redefine some names to avoid glitches. - - Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Paul Eggert. */ - -#include <stdlib.h> -#include "stdlib-safer.h" - -#if defined(_WIN32) -char *mkdtemp(char *template); -int mkstemp(char*); -char *secure_getenv(const char *name); -#endif - -#undef mkstemp -#define mkstemp mkstemp_safer - -#if GNULIB_MKOSTEMP -# define mkostemp mkostemp_safer -#endif - -#if GNULIB_MKOSTEMPS -# define mkostemps mkostemps_safer -#endif - -#if GNULIB_MKSTEMPS -# define mkstemps mkstemps_safer -#endif diff --git a/contrib/tools/bison/lib/stdlib-safer.h b/contrib/tools/bison/lib/stdlib-safer.h deleted file mode 100644 index 1e3149370e..0000000000 --- a/contrib/tools/bison/lib/stdlib-safer.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Invoke stdlib.h functions, but avoid some glitches. - - Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Paul Eggert. */ - -int mkstemp_safer (char *); - -#if GNULIB_MKOSTEMP -int mkostemp_safer (char *, int); -#endif - -#if GNULIB_MKOSTEMPS -int mkostemps_safer (char *, int, int); -#endif - -#if GNULIB_MKSTEMPS -int mkstemps_safer (char *, int); -#endif diff --git a/contrib/tools/bison/lib/str-two-way.h b/contrib/tools/bison/lib/str-two-way.h deleted file mode 100644 index 707145dbdd..0000000000 --- a/contrib/tools/bison/lib/str-two-way.h +++ /dev/null @@ -1,452 +0,0 @@ -/* Byte-wise substring search, using the Two-Way algorithm. - Copyright (C) 2008-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Eric Blake <ebb9@byu.net>, 2008. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ - -/* Before including this file, you need to include <config.h> and - <string.h>, and define: - RESULT_TYPE A macro that expands to the return type. - AVAILABLE(h, h_l, j, n_l) - A macro that returns nonzero if there are - at least N_L bytes left starting at H[J]. - H is 'unsigned char *', H_L, J, and N_L - are 'size_t'; H_L is an lvalue. For - NUL-terminated searches, H_L can be - modified each iteration to avoid having - to compute the end of H up front. - - For case-insensitivity, you may optionally define: - CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L - characters of P1 and P2 are equal. - CANON_ELEMENT(c) A macro that canonicalizes an element right after - it has been fetched from one of the two strings. - The argument is an 'unsigned char'; the result - must be an 'unsigned char' as well. - - This file undefines the macros documented above, and defines - LONG_NEEDLE_THRESHOLD. -*/ - -#include <limits.h> -#include <stdint.h> - -/* We use the Two-Way string matching algorithm (also known as - Chrochemore-Perrin), which guarantees linear complexity with - constant space. Additionally, for long needles, we also use a bad - character shift table similar to the Boyer-Moore algorithm to - achieve improved (potentially sub-linear) performance. - - See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260, - http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm, - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf -*/ - -/* Point at which computing a bad-byte shift table is likely to be - worthwhile. Small needles should not compute a table, since it - adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a - speedup no greater than a factor of NEEDLE_LEN. The larger the - needle, the better the potential performance gain. On the other - hand, on non-POSIX systems with CHAR_BIT larger than eight, the - memory required for the table is prohibitive. */ -#if CHAR_BIT < 10 -# define LONG_NEEDLE_THRESHOLD 32U -#else -# define LONG_NEEDLE_THRESHOLD SIZE_MAX -#endif - -#ifndef MAX -# define MAX(a, b) ((a < b) ? (b) : (a)) -#endif - -#ifndef CANON_ELEMENT -# define CANON_ELEMENT(c) c -#endif -#ifndef CMP_FUNC -# define CMP_FUNC memcmp -#endif - -/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN. - Return the index of the first byte in the right half, and set - *PERIOD to the global period of the right half. - - The global period of a string is the smallest index (possibly its - length) at which all remaining bytes in the string are repetitions - of the prefix (the last repetition may be a subset of the prefix). - - When NEEDLE is factored into two halves, a local period is the - length of the smallest word that shares a suffix with the left half - and shares a prefix with the right half. All factorizations of a - non-empty NEEDLE have a local period of at least 1 and no greater - than NEEDLE_LEN. - - A critical factorization has the property that the local period - equals the global period. All strings have at least one critical - factorization with the left half smaller than the global period. - And while some strings have more than one critical factorization, - it is provable that with an ordered alphabet, at least one of the - critical factorizations corresponds to a maximal suffix. - - Given an ordered alphabet, a critical factorization can be computed - in linear time, with 2 * NEEDLE_LEN comparisons, by computing the - shorter of two ordered maximal suffixes. The ordered maximal - suffixes are determined by lexicographic comparison while tracking - periodicity. */ -static size_t -critical_factorization (const unsigned char *needle, size_t needle_len, - size_t *period) -{ - /* Index of last byte of left half, or SIZE_MAX. */ - size_t max_suffix, max_suffix_rev; - size_t j; /* Index into NEEDLE for current candidate suffix. */ - size_t k; /* Offset into current period. */ - size_t p; /* Intermediate period. */ - unsigned char a, b; /* Current comparison bytes. */ - - /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered - out 0-length needles. */ - if (needle_len < 3) - { - *period = 1; - return needle_len - 1; - } - - /* Invariants: - 0 <= j < NEEDLE_LEN - 1 - -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) - min(max_suffix, max_suffix_rev) < global period of NEEDLE - 1 <= p <= global period of NEEDLE - p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] - 1 <= k <= p - */ - - /* Perform lexicographic search. */ - max_suffix = SIZE_MAX; - j = 0; - k = p = 1; - while (j + k < needle_len) - { - a = CANON_ELEMENT (needle[j + k]); - b = CANON_ELEMENT (needle[max_suffix + k]); - if (a < b) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix; - } - else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } - else /* b < a */ - { - /* Suffix is larger, start over from current location. */ - max_suffix = j++; - k = p = 1; - } - } - *period = p; - - /* Perform reverse lexicographic search. */ - max_suffix_rev = SIZE_MAX; - j = 0; - k = p = 1; - while (j + k < needle_len) - { - a = CANON_ELEMENT (needle[j + k]); - b = CANON_ELEMENT (needle[max_suffix_rev + k]); - if (b < a) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix_rev; - } - else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } - else /* a < b */ - { - /* Suffix is larger, start over from current location. */ - max_suffix_rev = j++; - k = p = 1; - } - } - - /* Choose the shorter suffix. Return the index of the first byte of - the right half, rather than the last byte of the left half. - - For some examples, 'banana' has two critical factorizations, both - exposed by the two lexicographic extreme suffixes of 'anana' and - 'nana', where both suffixes have a period of 2. On the other - hand, with 'aab' and 'bba', both strings have a single critical - factorization of the last byte, with the suffix having a period - of 1. While the maximal lexicographic suffix of 'aab' is 'b', - the maximal lexicographic suffix of 'bba' is 'ba', which is not a - critical factorization. Conversely, the maximal reverse - lexicographic suffix of 'a' works for 'bba', but not 'ab' for - 'aab'. The shorter suffix of the two will always be a critical - factorization. */ - if (max_suffix_rev + 1 < max_suffix + 1) - return max_suffix + 1; - *period = p; - return max_suffix_rev + 1; -} - -/* Return the first location of non-empty NEEDLE within HAYSTACK, or - NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This - method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. - Performance is guaranteed to be linear, with an initialization cost - of 2 * NEEDLE_LEN comparisons. - - If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at - most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. - If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * - HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ -static RETURN_TYPE -two_way_short_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) -{ - size_t i; /* Index into current byte of NEEDLE. */ - size_t j; /* Index into current window of HAYSTACK. */ - size_t period; /* The period of the right half of needle. */ - size_t suffix; /* The index of the right half of needle. */ - - /* Factor the needle into two halves, such that the left half is - smaller than the global period, and the right half is - periodic (with a period as large as NEEDLE_LEN - suffix). */ - suffix = critical_factorization (needle, needle_len, &period); - - /* Perform the search. Each iteration compares the right half - first. */ - if (CMP_FUNC (needle, needle + period, suffix) == 0) - { - /* Entire needle is periodic; a mismatch in the left half can - only advance by the period, so use memory to avoid rescanning - known occurrences of the period in the right half. */ - size_t memory = 0; - j = 0; - while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = MAX (suffix, memory); - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } - } - else - { - /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ - period = MAX (suffix, needle_len - suffix) + 1; - j = 0; - while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = suffix; - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } - } - return NULL; -} - -/* Return the first location of non-empty NEEDLE within HAYSTACK, or - NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This - method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. - Performance is guaranteed to be linear, with an initialization cost - of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. - - If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at - most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, - and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. - If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * - HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and - sublinear performance is not possible. */ -static RETURN_TYPE -two_way_long_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) -{ - size_t i; /* Index into current byte of NEEDLE. */ - size_t j; /* Index into current window of HAYSTACK. */ - size_t period; /* The period of the right half of needle. */ - size_t suffix; /* The index of the right half of needle. */ - size_t shift_table[1U << CHAR_BIT]; /* See below. */ - - /* Factor the needle into two halves, such that the left half is - smaller than the global period, and the right half is - periodic (with a period as large as NEEDLE_LEN - suffix). */ - suffix = critical_factorization (needle, needle_len, &period); - - /* Populate shift_table. For each possible byte value c, - shift_table[c] is the distance from the last occurrence of c to - the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. - shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ - for (i = 0; i < 1U << CHAR_BIT; i++) - shift_table[i] = needle_len; - for (i = 0; i < needle_len; i++) - shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; - - /* Perform the search. Each iteration compares the right half - first. */ - if (CMP_FUNC (needle, needle + period, suffix) == 0) - { - /* Entire needle is periodic; a mismatch in the left half can - only advance by the period, so use memory to avoid rescanning - known occurrences of the period in the right half. */ - size_t memory = 0; - size_t shift; - j = 0; - while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - if (memory && shift < period) - { - /* Since needle is periodic, but the last period has - a byte out of place, there can be no match until - after the mismatch. */ - shift = needle_len - period; - } - memory = 0; - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = MAX (suffix, memory); - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } - } - else - { - /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ - size_t shift; - period = MAX (suffix, needle_len - suffix) + 1; - j = 0; - while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = suffix; - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } - } - return NULL; -} - -#undef AVAILABLE -#undef CANON_ELEMENT -#undef CMP_FUNC -#undef MAX -#undef RETURN_TYPE diff --git a/contrib/tools/bison/lib/strchrnul.c b/contrib/tools/bison/lib/strchrnul.c deleted file mode 100644 index 4308889950..0000000000 --- a/contrib/tools/bison/lib/strchrnul.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Searching in a string. - Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include "string--.h" - -/* Find the first occurrence of C in S or the final NUL byte. */ -char * -strchrnul (const char *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - if (!c) - return rawmemchr (s, 0); - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (!*char_ptr || *char_ptr == c) - return (char *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 or - longword2 is zero. - - Let's consider longword1. We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 or longword2 is zero is equivalent - to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine - this into a single test, whether (tmp1 | tmp2) is nonzero. - - This test can read more than one byte beyond the end of a string, - depending on where the terminating NUL is encountered. However, - this is considered safe since the initialization phase ensured - that the read will be aligned, therefore, the read will not cross - page boundaries and will not cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - longword longword2 = *longword_ptr; - - if (((((longword1 - repeated_one) & ~longword1) - | ((longword2 - repeated_one) & ~longword2)) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == 0 or == c. On little-endian machines, - we could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr && (*char_ptr != c)) - char_ptr++; - return (char *) char_ptr; -} diff --git a/contrib/tools/bison/lib/strdup.c b/contrib/tools/bison/lib/strdup.c deleted file mode 100644 index 5826ab02af..0000000000 --- a/contrib/tools/bison/lib/strdup.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2013 Free Software - Foundation, Inc. - - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ - -#ifndef _LIBC -# include <config.h> -#endif - -/* Get specification. */ -#include <string.h> - -#include <stdlib.h> - -#undef __strdup -#ifdef _LIBC -# undef strdup -#endif - -#ifndef weak_alias -# define __strdup strdup -#endif - -/* Duplicate S, returning an identical malloc'd string. */ -char * -__strdup (const char *s) -{ - size_t len = strlen (s) + 1; - void *new = malloc (len); - - if (new == NULL) - return NULL; - - return (char *) memcpy (new, s, len); -} -#ifdef libc_hidden_def -libc_hidden_def (__strdup) -#endif -#ifdef weak_alias -weak_alias (__strdup, strdup) -#endif diff --git a/contrib/tools/bison/lib/strsignal.c b/contrib/tools/bison/lib/strsignal.c deleted file mode 100644 index 20d604ff38..0000000000 --- a/contrib/tools/bison/lib/strsignal.c +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (C) 1991, 1994-2002, 2005, 2008-2013 Free Software Foundation, - Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef _LIBC -# include <config.h> -#endif - -/* Specification. */ -#include <string.h> - -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> - -#ifdef _LIBC -# include <libintl.h> -#else /* !_LIBC */ -# include "gettext.h" -# define _(msgid) gettext (msgid) -# define N_(msgid) gettext_noop (msgid) -#endif /* _LIBC */ - -#ifdef _LIBC -# include <bits/libc-lock.h> -#else /* !_LIBC */ -# include "glthread/lock.h" -# include "glthread/tls.h" -# define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME) -# define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) -# define __libc_key_t gl_tls_key_t -# define __libc_getspecific(NAME) gl_tls_get ((NAME)) -# define __libc_setspecific(NAME, POINTER) gl_tls_set ((NAME), (POINTER)) -#if defined(_MSC_VER) -# define __snprintf _snprintf -#else -# define __snprintf snprintf -#endif -#endif /* _LIBC */ - -#ifdef _LIBC - -/* Defined in siglist.c. */ -extern const char *const _sys_siglist[]; -extern const char *const _sys_siglist_internal[] attribute_hidden; - -#else /* !_LIBC */ - -/* NetBSD declares sys_siglist in unistd.h. */ -# if HAVE_UNISTD_H -# include <unistd.h> -# endif - -# define INTUSE(x) (x) - -# if HAVE_DECL_SYS_SIGLIST -# undef _sys_siglist -# define _sys_siglist sys_siglist -# else /* !HAVE_DECL_SYS_SIGLIST */ -# ifndef NSIG -# define NSIG 32 -# endif /* NSIG */ -# if !HAVE_DECL__SYS_SIGLIST -static const char *_sys_siglist[NSIG]; -# endif -# endif /* !HAVE_DECL_SYS_SIGLIST */ - -#endif /* _LIBC */ - -static __libc_key_t key; - -/* If nonzero the key allocation failed and we should better use a - static buffer than fail. */ -#define BUFFERSIZ 100 -static char local_buf[BUFFERSIZ]; -static char *static_buf; - -/* Destructor for the thread-specific data. */ -static void init (void); -static void free_key_mem (void *mem); -static char *getbuffer (void); - - -/* Return a string describing the meaning of the signal number SIGNUM. */ -char * -strsignal (int signum) -{ - const char *desc; - __libc_once_define (static, once); - - /* If we have not yet initialized the buffer do it now. */ - __libc_once (once, init); - - if ( -#ifdef SIGRTMIN - (signum >= SIGRTMIN && signum <= SIGRTMAX) || -#endif - signum < 0 || signum >= NSIG - || (desc = INTUSE(_sys_siglist)[signum]) == NULL) - { - char *buffer = getbuffer (); - int len; -#ifdef SIGRTMIN - if (signum >= SIGRTMIN && signum <= SIGRTMAX) - len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), - signum - (int) SIGRTMIN); - else -#endif - len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), - signum); - if (len >= BUFFERSIZ) - buffer = NULL; - else - buffer[len] = '\0'; - - return buffer; - } - - return (char *) _(desc); -} - - -/* Initialize buffer. */ -static void -init (void) -{ -#ifdef _LIBC - if (__libc_key_create (&key, free_key_mem)) - /* Creating the key failed. This means something really went - wrong. In any case use a static buffer which is better than - nothing. */ - static_buf = local_buf; -#else /* !_LIBC */ - gl_tls_key_init (key, free_key_mem); - -# if !HAVE_DECL_SYS_SIGLIST - memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist); - - /* No need to use a do {} while (0) here since init_sig(...) must expand - to a complete statement. (We cannot use the ISO C99 designated array - initializer syntax since it is not supported by ANSI C compilers and - since some signal numbers might exceed NSIG.) */ -# define init_sig(sig, abbrev, desc) \ - if (sig >= 0 && sig < NSIG) \ - _sys_siglist[sig] = desc; - -# include "siglist.h" - -# undef init_sig - -# endif /* !HAVE_DECL_SYS_SIGLIST */ -#endif /* !_LIBC */ -} - - -/* Free the thread specific data, this is done if a thread terminates. */ -static void -free_key_mem (void *mem) -{ - free (mem); - __libc_setspecific (key, NULL); -} - - -/* Return the buffer to be used. */ -static char * -getbuffer (void) -{ - char *result; - - if (static_buf != NULL) - result = static_buf; - else - { - /* We don't use the static buffer and so we have a key. Use it - to get the thread-specific buffer. */ - result = __libc_getspecific (key); - if (result == NULL) - { - /* No buffer allocated so far. */ - result = malloc (BUFFERSIZ); - if (result == NULL) - /* No more memory available. We use the static buffer. */ - result = local_buf; - else - __libc_setspecific (key, result); - } - } - - return result; -} diff --git a/contrib/tools/bison/lib/strstr.c b/contrib/tools/bison/lib/strstr.c deleted file mode 100644 index b91acec7c8..0000000000 --- a/contrib/tools/bison/lib/strstr.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2013 Free Software - Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, see <http://www.gnu.org/licenses/>. */ - -/* This particular implementation was written by Eric Blake, 2008. */ - -#ifndef _LIBC -# include <config.h> -#endif - -/* Specification of strstr. */ -#include <string.h> - -#include <stdbool.h> - -#ifndef _LIBC -# define __builtin_expect(expr, val) (expr) -#endif - -#define RETURN_TYPE char * -#define AVAILABLE(h, h_l, j, n_l) \ - (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ - && ((h_l) = (j) + (n_l))) -#include "str-two-way.h" - -/* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK - if NEEDLE is empty, otherwise NULL if NEEDLE is not found in - HAYSTACK. */ -char * -strstr (const char *haystack_start, const char *needle_start) -{ - const char *haystack = haystack_start; - const char *needle = needle_start; - size_t needle_len; /* Length of NEEDLE. */ - size_t haystack_len; /* Known minimum length of HAYSTACK. */ - bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ - - /* Determine length of NEEDLE, and in the process, make sure - HAYSTACK is at least as long (no point processing all of a long - NEEDLE if HAYSTACK is too short). */ - while (*haystack && *needle) - ok &= *haystack++ == *needle++; - if (*needle) - return NULL; - if (ok) - return (char *) haystack_start; - - /* Reduce the size of haystack using strchr, since it has a smaller - linear coefficient than the Two-Way algorithm. */ - needle_len = needle - needle_start; - haystack = strchr (haystack_start + 1, *needle_start); - if (!haystack || __builtin_expect (needle_len == 1, 0)) - return (char *) haystack; - needle -= needle_len; - haystack_len = (haystack > haystack_start + needle_len ? 1 - : needle_len + haystack_start - haystack); - - /* Perform the search. Abstract memory is considered to be an array - of 'unsigned char' values, not an array of 'char' values. See - ISO C 99 section 6.2.6.1. */ - if (needle_len < LONG_NEEDLE_THRESHOLD) - return two_way_short_needle ((const unsigned char *) haystack, - haystack_len, - (const unsigned char *) needle, needle_len); - return two_way_long_needle ((const unsigned char *) haystack, haystack_len, - (const unsigned char *) needle, needle_len); -} - -#undef LONG_NEEDLE_THRESHOLD diff --git a/contrib/tools/bison/lib/tempname.c b/contrib/tools/bison/lib/tempname.c deleted file mode 100644 index 9975449a89..0000000000 --- a/contrib/tools/bison/lib/tempname.c +++ /dev/null @@ -1,306 +0,0 @@ -/* tempname.c - generate the name of a temporary file. - - Copyright (C) 1991-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Extracted from glibc sysdeps/posix/tempname.c. See also tmpdir.c. */ - -#if !_LIBC -# include <config.h> -# include "tempname.h" -#endif - -#include <sys/types.h> -#include <assert.h> - -#include <errno.h> -#ifndef __set_errno -# define __set_errno(Val) errno = (Val) -#endif - -#include <stdio.h> -#ifndef P_tmpdir -# define P_tmpdir "/tmp" -#endif -#ifndef TMP_MAX -# define TMP_MAX 238328 -#endif -#ifndef __GT_FILE -# define __GT_FILE 0 -# define __GT_DIR 1 -# define __GT_NOCREATE 2 -#endif -#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \ - || GT_NOCREATE != __GT_NOCREATE) -# error report this to bug-gnulib@gnu.org -#endif - -#include <stddef.h> -#include <stdlib.h> -#include <string.h> - -#include <fcntl.h> -#include <sys/time.h> -#include <stdint.h> -#include "unistd--.h" - -#include <sys/stat.h> - -#if _LIBC -# define struct_stat64 struct stat64 -#else -# define struct_stat64 struct stat -# define __gen_tempname gen_tempname -# define __getpid getpid -# define __gettimeofday gettimeofday -# define __mkdir mkdir -# define __open open -# define __lxstat64(version, file, buf) lstat (file, buf) -# define __secure_getenv secure_getenv -#endif - -#ifdef _LIBC -# include <hp-timing.h> -# if HP_TIMING_AVAIL -# define RANDOM_BITS(Var) \ - if (__builtin_expect (value == UINT64_C (0), 0)) \ - { \ - /* If this is the first time this function is used initialize \ - the variable we accumulate the value in to some somewhat \ - random value. If we'd not do this programs at startup time \ - might have a reduced set of possible names, at least on slow \ - machines. */ \ - struct timeval tv; \ - __gettimeofday (&tv, NULL); \ - value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \ - } \ - HP_TIMING_NOW (Var) -# endif -#endif - -/* Use the widest available unsigned type if uint64_t is not - available. The algorithm below extracts a number less than 62**6 - (approximately 2**35.725) from uint64_t, so ancient hosts where - uintmax_t is only 32 bits lose about 3.725 bits of randomness, - which is better than not having mkstemp at all. */ -#if !defined UINT64_MAX && !defined uint64_t -# define uint64_t uintmax_t -#endif - -#if _LIBC -/* Return nonzero if DIR is an existent directory. */ -static int -direxists (const char *dir) -{ - struct_stat64 buf; - return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode); -} - -/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is - non-null and exists, uses it; otherwise uses the first of $TMPDIR, - P_tmpdir, /tmp that exists. Copies into TMPL a template suitable - for use with mk[s]temp. Will fail (-1) if DIR is non-null and - doesn't exist, none of the searched dirs exists, or there's not - enough space in TMPL. */ -int -__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, - int try_tmpdir) -{ - const char *d; - size_t dlen, plen; - - if (!pfx || !pfx[0]) - { - pfx = "file"; - plen = 4; - } - else - { - plen = strlen (pfx); - if (plen > 5) - plen = 5; - } - - if (try_tmpdir) - { - d = __secure_getenv ("TMPDIR"); - if (d != NULL && direxists (d)) - dir = d; - else if (dir != NULL && direxists (dir)) - /* nothing */ ; - else - dir = NULL; - } - if (dir == NULL) - { - if (direxists (P_tmpdir)) - dir = P_tmpdir; - else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) - dir = "/tmp"; - else - { - __set_errno (ENOENT); - return -1; - } - } - - dlen = strlen (dir); - while (dlen > 1 && dir[dlen - 1] == '/') - dlen--; /* remove trailing slashes */ - - /* check we have room for "${dir}/${pfx}XXXXXX\0" */ - if (tmpl_len < dlen + 1 + plen + 6 + 1) - { - __set_errno (EINVAL); - return -1; - } - - sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx); - return 0; -} -#endif /* _LIBC */ - -/* These are the characters used in temporary file names. */ -static const char letters[] = -"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - -/* Generate a temporary file name based on TMPL. TMPL must match the - rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). - The name constructed does not exist at the time of the call to - __gen_tempname. TMPL is overwritten with the result. - - KIND may be one of: - __GT_NOCREATE: simply verify that the name does not exist - at the time of the call. - __GT_FILE: create the file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. - __GT_DIR: create a directory, which will be mode 0700. - - We use a clever algorithm to get hard-to-predict names. */ -int -__gen_tempname (char *tmpl, int suffixlen, int flags, int kind) -{ - int len; - char *XXXXXX; - static uint64_t value; - uint64_t random_time_bits; - unsigned int count; - int fd = -1; - int save_errno = errno; - struct_stat64 st; - - /* A lower bound on the number of temporary files to attempt to - generate. The maximum total number of temporary file names that - can exist for a given template is 62**6. It should never be - necessary to try all of these combinations. Instead if a reasonable - number of names is tried (we define reasonable as 62**3) fail to - give the system administrator the chance to remove the problems. */ -#define ATTEMPTS_MIN (62 * 62 * 62) - - /* The number of times to attempt to generate a temporary file. To - conform to POSIX, this must be no smaller than TMP_MAX. */ -#if ATTEMPTS_MIN < TMP_MAX - unsigned int attempts = TMP_MAX; -#else - unsigned int attempts = ATTEMPTS_MIN; -#endif - - len = strlen (tmpl); - if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6)) - { - __set_errno (EINVAL); - return -1; - } - - /* This is where the Xs start. */ - XXXXXX = &tmpl[len - 6 - suffixlen]; - - /* Get some more or less random data. */ -#ifdef RANDOM_BITS - RANDOM_BITS (random_time_bits); -#else - { - struct timeval tv; - __gettimeofday (&tv, NULL); - random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; - } -#endif - value += random_time_bits ^ __getpid (); - - for (count = 0; count < attempts; value += 7777, ++count) - { - uint64_t v = value; - - /* Fill in the random bits. */ - XXXXXX[0] = letters[v % 62]; - v /= 62; - XXXXXX[1] = letters[v % 62]; - v /= 62; - XXXXXX[2] = letters[v % 62]; - v /= 62; - XXXXXX[3] = letters[v % 62]; - v /= 62; - XXXXXX[4] = letters[v % 62]; - v /= 62; - XXXXXX[5] = letters[v % 62]; - - switch (kind) - { - case __GT_FILE: - fd = __open (tmpl, - (flags & ~O_ACCMODE) - | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; - - case __GT_DIR: - fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); - break; - - case __GT_NOCREATE: - /* This case is backward from the other three. __gen_tempname - succeeds if __xstat fails because the name does not exist. - Note the continue to bypass the common logic at the bottom - of the loop. */ - if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) - { - if (errno == ENOENT) - { - __set_errno (save_errno); - return 0; - } - else - /* Give up now. */ - return -1; - } - continue; - - default: - assert (! "invalid KIND in __gen_tempname"); - abort (); - } - - if (fd >= 0) - { - __set_errno (save_errno); - return fd; - } - else if (errno != EEXIST) - return -1; - } - - /* We got out of the loop because we ran out of combinations to try. */ - __set_errno (EEXIST); - return -1; -} diff --git a/contrib/tools/bison/lib/tempname.h b/contrib/tools/bison/lib/tempname.h deleted file mode 100644 index 333267dfd0..0000000000 --- a/contrib/tools/bison/lib/tempname.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Create a temporary file or directory. - - Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* header written by Eric Blake */ - -#ifndef GL_TEMPNAME_H -# define GL_TEMPNAME_H - -# include <stdio.h> - -# ifdef __GT_FILE -# define GT_FILE __GT_FILE -# define GT_DIR __GT_DIR -# define GT_NOCREATE __GT_NOCREATE -# else -# define GT_FILE 0 -# define GT_DIR 1 -# define GT_NOCREATE 2 -# endif - -/* Generate a temporary file name based on TMPL. TMPL must match the - rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). - The name constructed does not exist at the time of the call to - gen_tempname. TMPL is overwritten with the result. - - KIND may be one of: - GT_NOCREATE: simply verify that the name does not exist - at the time of the call. - GT_FILE: create a large file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. - GT_DIR: create a directory, which will be mode 0700. - - We use a clever algorithm to get hard-to-predict names. */ -extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind); - -#endif /* GL_TEMPNAME_H */ diff --git a/contrib/tools/bison/lib/timevar.c b/contrib/tools/bison/lib/timevar.c index a9dbdbdee5..f6a91f4014 100644 --- a/contrib/tools/bison/lib/timevar.c +++ b/contrib/tools/bison/lib/timevar.c @@ -38,7 +38,7 @@ modifications that are under control of the IN_GCC preprocessor variable. The !IN_GCC part of this file is specific to Bison. */ -# include "bison-system.h" +# include "../src/system.h" # if HAVE_SYS_TIME_H # include <sys/time.h> # endif diff --git a/contrib/tools/bison/lib/unistd--.h b/contrib/tools/bison/lib/unistd--.h deleted file mode 100644 index fee7ecf03d..0000000000 --- a/contrib/tools/bison/lib/unistd--.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Like unistd.h, but redefine some names to avoid glitches. - - Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Written by Paul Eggert. */ - -#include <unistd.h> -#include "unistd-safer.h" - -#if defined(_WIN32) -# include <process.h> -#endif - -#undef dup -#define dup dup_safer - -#undef pipe -#define pipe pipe_safer - -#if GNULIB_PIPE2_SAFER -# undef pipe2 -# define pipe2 pipe2_safer -#endif diff --git a/contrib/tools/bison/lib/vasnprintf.c b/contrib/tools/bison/lib/vasnprintf.c index 4de22819fa..34cd753379 100644 --- a/contrib/tools/bison/lib/vasnprintf.c +++ b/contrib/tools/bison/lib/vasnprintf.c @@ -54,7 +54,7 @@ # include <config.h> #endif #ifndef IN_LIBINTL -# include "palloca.h" +# include <alloca.h> #endif /* Specification. */ diff --git a/contrib/tools/bison/lib/xvasprintf.c b/contrib/tools/bison/lib/xvasprintf.c deleted file mode 100644 index 9c93492b80..0000000000 --- a/contrib/tools/bison/lib/xvasprintf.c +++ /dev/null @@ -1,117 +0,0 @@ -/* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <config.h> - -/* Specification. */ -#include "xvasprintf.h" - -#include <errno.h> -#include <limits.h> -#include <string.h> -#include <stdio.h> - -#include "xalloc.h" - -/* Checked size_t computations. */ -#include "xsize.h" - -static char * -xstrcat (size_t argcount, va_list args) -{ - char *result; - va_list ap; - size_t totalsize; - size_t i; - char *p; - - /* Determine the total size. */ - totalsize = 0; - va_copy (ap, args); - for (i = argcount; i > 0; i--) - { - const char *next = va_arg (ap, const char *); - totalsize = xsum (totalsize, strlen (next)); - } - va_end (ap); - - /* Test for overflow in the summing pass above or in (totalsize + 1) below. - Also, don't return a string longer than INT_MAX, for consistency with - vasprintf(). */ - if (totalsize == SIZE_MAX || totalsize > INT_MAX) - { -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else - errno = EOVERFLOW; -#endif - return NULL; - } - - /* Allocate and fill the result string. */ - result = XNMALLOC (totalsize + 1, char); - p = result; - for (i = argcount; i > 0; i--) - { - const char *next = va_arg (args, const char *); - size_t len = strlen (next); - memcpy (p, next, len); - p += len; - } - *p = '\0'; - - return result; -} - -#if defined(_MSC_VER) -int vasprintf(char **resultp, const char *format, va_list args); -#endif - -char * -xvasprintf (const char *format, va_list args) -{ - char *result; - - /* Recognize the special case format = "%s...%s". It is a frequently used - idiom for string concatenation and needs to be fast. We don't want to - have a separate function xstrcat() for this purpose. */ - { - size_t argcount = 0; - const char *f; - - for (f = format;;) - { - if (*f == '\0') - /* Recognized the special case of string concatenation. */ - return xstrcat (argcount, args); - if (*f != '%') - break; - f++; - if (*f != 's') - break; - f++; - argcount++; - } - } - - if (vasprintf (&result, format, args) < 0) - { - if (errno == ENOMEM) - xalloc_die (); - return NULL; - } - - return result; -} diff --git a/contrib/tools/bison/lib/xvasprintf.h b/contrib/tools/bison/lib/xvasprintf.h deleted file mode 100644 index 1208fa193c..0000000000 --- a/contrib/tools/bison/lib/xvasprintf.h +++ /dev/null @@ -1,55 +0,0 @@ -/* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef _XVASPRINTF_H -#define _XVASPRINTF_H - -/* Get va_list. */ -#include <stdarg.h> - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The __-protected variants of the attributes 'format' and 'printf' are - accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because - gnulib and libintl do '#define printf __printf__' when they override - the 'printf' function. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -#else -# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Write formatted output to a string dynamically allocated with malloc(), - and return it. Upon [ENOMEM] memory allocation error, call xalloc_die. - On some other error - - [EOVERFLOW] resulting string length is > INT_MAX, - - [EINVAL] invalid format string, - - [EILSEQ] error during conversion between wide and multibyte characters, - return NULL. */ -extern char *xasprintf (const char *format, ...) - _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 2)); -extern char *xvasprintf (const char *format, va_list args) - _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 0)); - -#ifdef __cplusplus -} -#endif - -#endif /* _XVASPRINTF_H */ diff --git a/contrib/tools/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make index bad196cef6..27ea06b0e4 100644 --- a/contrib/tools/bison/lib/ya.make +++ b/contrib/tools/bison/lib/ya.make @@ -27,15 +27,8 @@ ELSE() ) ENDIF() -IF (OS_DARWIN) - CFLAGS( - -D_XOPEN_SOURCE=600 - ) -ENDIF() - IF (NOT OS_WINDOWS) CFLAGS( - GLOBAL -Dregcomp=gnu_regcomp GLOBAL -Dregerror=gnu_regerror GLOBAL -Dregfree=gnu_regfree GLOBAL -Dregexec=gnu_regexec @@ -75,24 +68,19 @@ SRCS( fd-safer-flag.c fd-safer.c fopen-safer.c - fstat.c get-errno.c getdtablesize.c getopt.c getopt1.c hash.c - itold.c isnanl.c isnand.c lbitset.c localcharset.c - lseek.c - lstat.c malloc.c malloca.c mbswidth.c mbrtowc.c - mkstemp-safer.c nl_langinfo.c pipe-safer.c pipe2-safer.c @@ -102,20 +90,10 @@ SRCS( printf-parse.c progname.c quotearg.c - raise.c - rawmemchr.c - readlink.c - rename.c - rmdir.c - secure_getenv.c sig-handler.c spawn-pipe.c - stat.c stpcpy.c - strchrnul.c - strdup.c stripslash.c - tempname.c timevar.c unistd.c vasnprintf.c @@ -129,7 +107,6 @@ SRCS( xmemdup0.c xsize.c xstrndup.c - xvasprintf.c ) IF (NOT MUSL) @@ -155,18 +132,13 @@ IF (OS_WINDOWS) SRCS( frexp.c wcrtomb.c - perror.c - strstr.c - mkstemp.c - strsignal.c - mkdtemp.c fseeko.c fopen.c ftello.c - localeconv.c msvc-inval.c msvc-nothrow.c open.c + raise.c sigaction.c sigprocmask.c snprintf.c |