summaryrefslogtreecommitdiffstats
path: root/libc/misc
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-30 02:54:42 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-30 02:54:42 +0000
commit92ac94812b84cef7d9bddfffd0446721a7a6ee06 (patch)
treea5a2c895d613afb96fb71c9c19be9ec266db30d7 /libc/misc
parentac02770c4a13eff9fef10c33ebb18d765f25a968 (diff)
downloaduClibc-alpine-92ac94812b84cef7d9bddfffd0446721a7a6ee06.tar.bz2
uClibc-alpine-92ac94812b84cef7d9bddfffd0446721a7a6ee06.tar.xz
Finalize the merge from the trunk. There are more files to be
merged, but they will be done manually.
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/error/err.c2
-rw-r--r--libc/misc/glob/glob.c2
-rw-r--r--libc/misc/internals/Makefile8
-rw-r--r--libc/misc/internals/__uClibc_main.c45
-rw-r--r--libc/misc/pthread/weaks.c6
-rw-r--r--libc/misc/sysvipc/ipc.h4
-rw-r--r--libc/misc/sysvipc/msgq.c14
-rw-r--r--libc/misc/sysvipc/shm.c14
-rw-r--r--libc/misc/time/time.c27
9 files changed, 71 insertions, 51 deletions
diff --git a/libc/misc/error/err.c b/libc/misc/error/err.c
index 5c53e545f..0d0637148 100644
--- a/libc/misc/error/err.c
+++ b/libc/misc/error/err.c
@@ -34,7 +34,7 @@ static void vwarn_work(const char *format, va_list args, int showerr)
f = fmt + 11; /* At 11. */
if (showerr) {
f -= 4; /* At 7. */
- _susv3_strerror_r(errno, buf, sizeof(buf));
+ __xpg_strerror_r(errno, buf, sizeof(buf));
}
__STDIO_AUTO_THREADLOCK(stderr);
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index 14e2a6e22..a93cf0ab4 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.c
@@ -59,7 +59,7 @@ int glob_pattern_p(const char *pattern, int quote)
return 1;
case '\\':
- if (quote)
+ if (quote && p[1] != '\0')
++p;
break;
diff --git a/libc/misc/internals/Makefile b/libc/misc/internals/Makefile
index 23816b38d..933b169a6 100644
--- a/libc/misc/internals/Makefile
+++ b/libc/misc/internals/Makefile
@@ -31,7 +31,7 @@ OBJS=$(COBJS)
OBJ_LIST=../../obj.misc.internals
-all: $(OBJ_LIST) interp.o
+all: $(OBJ_LIST) interp.o static.o
$(OBJ_LIST): $(OBJS)
echo $(patsubst %, misc/internals/%, $(OBJS)) > $(OBJ_LIST)
@@ -44,11 +44,7 @@ interp.c: Makefile
"(\".interp\"))) =\""$(DYNAMIC_LINKER)"\";" >> interp.c
echo "#endif" >> interp.c
-interp.o: interp.c
- $(CC) $(CFLAGS) -c $< -o $@
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-$(COBJS): %.o : %.c
+$(COBJS) interp.o static.o: %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index a33e6fe4a..21864ba4f 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -32,7 +32,7 @@ extern void __guard_setup(void);
/*
* Prototypes.
*/
-extern int main(int argc, char **argv, char **envp);
+extern void *__libc_stack_end;
extern void weak_function _stdio_init(void);
extern int *weak_const_function __errno_location(void);
extern int *weak_const_function __h_errno_location(void);
@@ -165,14 +165,15 @@ void attribute_hidden (*__rtld_fini)(void) = NULL;
* are initialized, just before we call the application's main function.
*/
void __attribute__ ((__noreturn__))
-__uClibc_start_main(int argc, char **argv, char **envp,
- void (*app_init)(void), void (*app_fini)(void), void (*rtld_fini)(void))
+__uClibc_main(int (*main)(int, char **, char **), int argc,
+ char **argv, void (*app_init)(void), void (*app_fini)(void),
+ void (*rtld_fini)(void), void *stack_end)
{
#ifdef __ARCH_HAS_MMU__
unsigned long *aux_dat;
Elf32_auxv_t auxvt[AT_EGID + 1];
#endif
-
+ __libc_stack_end = stack_end;
/* We need to initialize uClibc. If we are dynamically linked this
* may have already been completed by the shared lib loader. We call
* __uClibc_init() regardless, to be sure the right thing happens. */
@@ -180,15 +181,19 @@ __uClibc_start_main(int argc, char **argv, char **envp,
__rtld_fini = rtld_fini;
- /* If we are dynamically linked, then ldso already did this for us. */
- if (__environ==NULL) {
- /* Statically linked. */
- __environ = envp;
+ /* The environment begins right after argv. */
+ __environ = &argv[argc + 1];
+
+ /* If the first thing after argv is the arguments
+ * the the environment is empty. */
+ if ((char *) __environ == *argv) {
+ /* Make __environ point to the NULL at argv[argc] */
+ __environ = &argv[argc];
}
/* Pull stuff from the ELF header when possible */
#ifdef __ARCH_HAS_MMU__
- aux_dat = (unsigned long*)envp;
+ aux_dat = (unsigned long*)__environ;
while (*aux_dat) {
aux_dat++;
}
@@ -247,23 +252,15 @@ __uClibc_start_main(int argc, char **argv, char **envp,
/*
* Finally, invoke application's main and then exit.
*/
- exit(main(argc, argv, envp));
+ exit(main(argc, argv, __environ));
}
-
-/* __uClibc_main is the old main stub of the uClibc. This
- * function is called from crt0 (uClibc 0.9.15 and older) after
- * ALL shared libraries are initialized, and just before we call
- * the application's main() function.
- *
- * Attention: This stub does not call the .init/.fini sections of
- * the application. If you need this, please fix your uClibc port
- * so that __uClibc_start_main is called by your crt0.S with
- * _init and _fini properly set.
-*/
+#ifdef _DL_FINI_CRT_COMPAT
+extern int weak_function main(int argc, char **argv, char **envp);
void __attribute__ ((__noreturn__))
-__uClibc_main(int argc, char **argv, char ** envp)
+__uClibc_start_main(int argc, char **argv, char **envp,
+ void (*app_fini)(void), void (*app_init)(void))
{
- __uClibc_start_main(argc, argv, envp, NULL, NULL, NULL);
+ __uClibc_main(main, argc, argv, app_init, app_fini, NULL, NULL);
}
-
+#endif
diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c
index 90b4f5494..89c26110c 100644
--- a/libc/misc/pthread/weaks.c
+++ b/libc/misc/pthread/weaks.c
@@ -23,7 +23,6 @@
static int __pthread_return_0 __P ((void));
static int __pthread_return_1 __P ((void));
-static void __pthread_return_void __P ((void));
/**********************************************************************/
/* Weaks for application/library use.
@@ -118,8 +117,3 @@ __pthread_return_1 (void)
{
return 1;
}
-
-static void
-__pthread_return_void (void)
-{
-}
diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h
index e1b94ad12..a5d443543 100644
--- a/libc/misc/sysvipc/ipc.h
+++ b/libc/misc/sysvipc/ipc.h
@@ -2,10 +2,10 @@
#define IPC_H
#include <syscall.h>
-#ifdef __NR_ipc
-
#define __IPC_64 0x100
+#ifdef __NR_ipc
+
/* The actual system call: all functions are multiplexed by this. */
extern int __syscall_ipc __P((int __call, int __first, int __second,
int __third, void *__ptr));
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index 411ea3ea4..758dbaa47 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -6,14 +6,18 @@
#ifdef L_msgctl
#ifdef __NR_msgctl
-_syscall3(int, msgctl, int, msqid, int, cmd | __IPC_64, struct msqid_ds *, buf);
-#else
+#define __NR___libc_msgctl __NR_msgctl
+_syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+#endif
/* Message queue control operation. */
-int msgctl (int msqid, int cmd, struct msqid_ds *buf)
+int msgctl(int msqid, int cmd, struct msqid_ds *buf)
{
- return __syscall_ipc(IPCOP_msgctl ,msqid ,cmd | __IPC_64 ,0 ,buf);
-}
+#ifdef __NR_msgctl
+ return __libc_msgctl(msqid, cmd | __IPC_64, buf);
+#else
+ return __syscall_ipc(IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
#endif
+}
#endif
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index d21d9f54b..29f3178d6 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -48,13 +48,17 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
#ifdef L_shmctl
/* Provide operations to control over shared memory segments. */
#ifdef __NR_shmctl
-_syscall3(int, shmctl, int, shmid, int, cmd | __IPC_64, struct shmid_ds *, buf);
-#else
-int shmctl (int shmid, int cmd, struct shmid_ds *buf)
+#define __NR___libc_shmctl __NR_shmctl
+_syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+#endif
+int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
- return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64 , 0, buf);
-}
+#ifdef __NR_shmctl
+ return __libc_shmctl(shmid, cmd | __IPC_64, buf);
+#else
+ return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
#endif
+}
#endif
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 7b1ae388b..f43bb8a3c 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -118,6 +118,15 @@
* Make lookup_tzname() static (as it should have been).
* Have strftime() get timezone information from the passed struct
* for the %z and %Z conversions when using struct tm extensions.
+ *
+ * Jul 24, 2004
+ * Fix 2 bugs in strftime related to glibc struct tm extensions.
+ * 1) Need to negate tm_gmtoff field value when used. (bug 336).
+ * 2) Deal with NULL ptr case for tm_zone field, which was causing
+ * segfaults in both the NIST/PCTS tests and the Python 2.4.1
+ * self-test suite.
+ * NOTE: We set uninitialized timezone names to "???", and this
+ * differs (intentionally) from glibc's behavior.
*/
#define _GNU_SOURCE
@@ -1066,7 +1075,7 @@ size_t __XL(strftime)(char *__restrict s, size_t maxsize,
#define RSP_TZUNLOCK ((void) 0)
#define RSP_TZNAME timeptr->tm_zone
-#define RSP_GMT_OFFSET timeptr->tm_gmtoff
+#define RSP_GMT_OFFSET (-timeptr->tm_gmtoff)
#else
@@ -1084,6 +1093,20 @@ size_t __XL(strftime)(char *__restrict s, size_t maxsize,
if (*p == 'Z') {
o = RSP_TZNAME;
+#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
+ /* Sigh... blasted glibc extensions. Of course we can't
+ * count on the pointer being valid. Best we can do is
+ * handle NULL, which looks to be all that glibc does.
+ * At least that catches the memset() with 0 case.
+ * NOTE: We handle this case differently than glibc!
+ * It uses system timezone name (based on tm_isdst) in this
+ * case... although it always seems to use the embedded
+ * tm_gmtoff value. What we'll do instead is treat the
+ * timezone name as unknown/invalid and return "???". */
+ if (!o) {
+ o = "???";
+ }
+#endif
assert(o != NULL);
#if 0
if (!o) { /* PARANOIA */
@@ -1939,7 +1962,9 @@ void tzset(void)
daylight = !!_time_tzinfo[1].tzname[0];
timezone = _time_tzinfo[0].gmt_offset;
+#if defined(__UCLIBC_HAS_TZ_FILE__)
FAST_DONE:
+#endif
TZUNLOCK;
}