newlib: fixup patch for new newlib version and adjust call sites.
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 1 Jun 2015 08:17:43 +0000 (10:17 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 1 Jun 2015 14:36:34 +0000 (16:36 +0200)
Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

16 files changed:
hake/ArchDefaults.hs
include/strings.h [deleted file]
include/sys/cdefs.h
include/sys/types.h
lib/newlib/newlib/libc/include/spawn__.h [moved from lib/newlib/newlib/libc/include/spawn.h with 100% similarity]
lib/newlib/newlib/libc/include/string.h
lib/newlib/newlib/libc/include/sys/features.h
lib/newlib/newlib/libc/locale/Hakefile
lib/newlib/newlib/libc/reent/Hakefile
lib/newlib/newlib/libc/search/Hakefile
lib/newlib/newlib/libc/string/Hakefile
lib/newlib/newlib/libc/time/Hakefile
lib/posixcompat/time.c
usr/openssh/src/defines.h
usr/openssh/src/openbsd-compat/bsd-misc.c
usr/ramfsd/main.c

index 5bb2e74..521a21a 100644 (file)
@@ -50,7 +50,11 @@ cFlags = [ Str s | s <- [ "-Wno-packed-bitfield-compat" ] ]
 cxxFlags = [ Str s | s <- [ "-Wno-packed-bitfield-compat" ] ]
        ++ commonCxxFlags
 
-cDefines options = [ Str ("-D"++s) | s <- [ "BARRELFISH", "BF_BINARY_PREFIX=\\\"\\\"" ] ]
+cDefines options = [ Str ("-D"++s) | s <- [ "BARRELFISH",
+                                            "BF_BINARY_PREFIX=\\\"\\\"",
+                                            "_WANT_IO_C99_FORMATS" -- newlib C99 printf format specifiers
+                                          ]
+                   ]
                    ++ Config.defines
                    ++ Config.arch_defines options
 
@@ -268,24 +272,12 @@ archive :: String -> Options -> [String] -> [String] -> String -> String -> [ Ru
 archive arch opts objs libs name libname =
     [ Str "rm -f ", Out arch libname ]
     ++ 
-    [ NL, Str "ar cr ", Out arch libname ] 
+    [ NL, Str "ar crT ", Out arch libname ]
     ++ 
     [ In BuildTree arch o | o <- objs ]
     ++
     if libs == [] then []
-                  else (
-      [ NL, Str ("rm -fr tmp-" ++ arch ++ name ++ "; mkdir tmp-" ++ arch ++ name) ]
-      ++
-      [ NL, Str ("cd tmp-" ++ arch ++ name ++ "; for i in ") ]
-      ++
-      [ In BuildTree arch a | a <- libs ]
-      ++
-      [ Str "; do mkdir `basename $$i`; (cd `basename $$i`; ar x ../../$$i); done" ]
-      ++
-      [ NL, Str "ar q ", Out arch libname, Str (" tmp-" ++ arch ++ name ++ "/*/*.o") ]
-      ++
-      [ NL, Str ("rm -fr tmp-" ++ arch ++ name) ]
-    )
+                  else [ In BuildTree arch a | a <- libs ]
     ++
     [ NL, Str "ranlib ", Out arch libname ]
 
diff --git a/include/strings.h b/include/strings.h
deleted file mode 100644 (file)
index aa00efa..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/include/strings.h,v 1.7 2008/11/03 10:22:19 kib Exp $
- */
-
-#ifndef _STRINGS_H_
-#define        _STRINGS_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-//#ifndef _SIZE_T_DECLARED
-//typedef      __size_t        size_t;
-//#define      _SIZE_T_DECLARED
-//#endif
-
-__BEGIN_DECLS
-//int   bcmp(const void *, const void *, size_t) __pure;       /* LEGACY */
-//void  bcopy(const void *, void *, size_t);                   /* LEGACY */
-//void  bzero(void *, size_t);                                 /* LEGACY */
-//int   ffs(int) __pure2;
-//#ifdef __BSD_VISIBLE
-//int   ffsl(long) __pure2;
-//int   ffsll(long long) __pure2;
-//int   fls(int) __pure2;
-//int   flsl(long) __pure2;
-//int   flsll(long long) __pure2;
-//#endif
-//char *index(const char *, int) __pure;                       /* LEGACY */
-//char *rindex(const char *, int) __pure;                      /* LEGACY */
-int     strcasecmp(const char *, const char *) __pure;
-int     strncasecmp(const char *, const char *, size_t) __pure;
-__END_DECLS
-
-#endif /* _STRINGS_H_ */
index ed68dad..e1b0d60 100644 (file)
  * Macro to test if we're using a specific version of gcc or later.
  */
 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+// this may already be defined by
+// lib/newlib/newlib/libc/include/sys/features.h
+#if !defined(__GNUC_PREREQ__)
 #define        __GNUC_PREREQ__(ma, mi) \
        (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
-#else
+#endif
+#elif !defined(__GNUC_PREREQ__)
 #define        __GNUC_PREREQ__(ma, mi) 0
 #endif
 
index d5edefd..635c220 100644 (file)
@@ -104,11 +104,6 @@ typedef __time_t  time_t;
 #define _TIME_T_DECLARED
 #endif
 
-struct timespec {
-    time_t  tv_sec;         /* seconds */
-    long    tv_nsec;        /* and nanoseconds */
-};
-
 #ifndef _UID_T_DECLARED
 typedef __uid_t   uid_t;
 #define _UID_T_DECLARED
index 92e08ae..d56aee8 100644 (file)
@@ -82,7 +82,7 @@ char  *_EXFUN(strdup,(const char *));
 #ifndef __STRICT_ANSI__
 char   *_EXFUN(_strdup_r,(struct _reent *, const char *));
 #endif
-#if __XSI_VISIBLE >= 700
+#if __XSI_VISIBLE >= 700 || defined(BARRELFISH)
 char   *_EXFUN(strndup,(const char *, size_t));
 #endif
 
index 4ad7fbd..8f26280 100644 (file)
@@ -41,7 +41,10 @@ extern "C" {
 # endif
 #endif /* __GNUC_PREREQ */
 /* Version with trailing underscores for BSD compatibility. */
+// this may already be defined by include/sys/cdefs.h
+#ifndef __GNUC_PREREQ__
 #define        __GNUC_PREREQ__(ma, mi) __GNUC_PREREQ(ma, mi)
+#endif
 
 /* RTEMS adheres to POSIX -- 1003.1b with some features from annexes.  */
 
index 3b1349a..6711cbf 100644 (file)
@@ -1,15 +1,16 @@
 if Config.libc == "newlib" then [ build library {
   target = "locale",
   cFiles = [
-    "locale.c",
     "fix_grouping.c",
+    "lctype.c",
     "ldpart.c",
     "lmessages.c",
-    "lnumeric.c",
     "lmonetary.c",
+    "lnumeric.c",
+    "locale.c",
     "nl_langinfo.c",
-    "timelocal.c",
-    "lctype.c" ],
+    "timelocal.c"
+    ],
   addCFlags = Config.newlibAddCFlags,
   omitCFlags = [ "-Wmissing-prototypes",
                  "-Wmissing-declarations",
index 08f3ab8..b60d21b 100644 (file)
@@ -8,28 +8,32 @@ in
 [ build library {
   target = "reent",
   cFiles = [
-    "reent.c",
-    "impure.c",
+    --"closer.c",
+    --"execr.c",
     --"fcntlr.c",
+    --"fstat64r.c",
+    --"fstatr.c",
     "getreent.c",
     --"gettimeofdayr.c",
+    "impure.c",
     --"isattyr.c",
     --"linkr.c",
+    --"lseek64r.c",
+    --"lseekr.c",
     --"mkdirr.c",
+    --"open64r.c",
+    --"openr.c",
+    --"readr.c",
+    "reent.c",
     --"renamer.c",
+    --"sbrkr.c",
     --"signalr.c",
     --"signgam.c",
-    --"sbrkr.c"
+    --"stat64r.c",
     --"statr.c",
-    --"timesr.c"
-    --"openr.c",
-    --"fstatr.c",
+    --"timesr.c",
     "unlinkr.c"
-    --"lseekr.c",
-    --"writer.c",
-    --"closer.c",
-    --"readr.c",
-    --"execr.c"
+    --"writer.c"
    ] ++ sbrk_files,
     addCFlags = Config.newlibAddCFlags,
     omitCFlags = [ "-Wmissing-prototypes",
index ff7e1ab..ebd8797 100644 (file)
@@ -1,8 +1,8 @@
 if Config.libc == "newlib" then [ build library {
   target = "search",
   cFiles = [
+    "bsd_qsort_r.c",
     "bsearch.c",
-    "qsort.c",
     "hash.c",
     "hash_bigkey.c",
     "hash_buf.c",
@@ -11,11 +11,14 @@ if Config.libc == "newlib" then [ build library {
     "hash_page.c",
     "hcreate.c",
     "hcreate_r.c",
+    "qsort.c",
+    "qsort_r.c",
     "tdelete.c",
     "tdestroy.c",
     "tfind.c",
     "tsearch.c",
-    "twalk.c"],
+    "twalk.c"
+    ],
   addCFlags  = Config.newlibAddCFlags,
   omitCFlags = [ "-Wold-style-definition",
                  "-Wstrict-prototypes",
index f3d52ef..85e42f8 100644 (file)
@@ -1,26 +1,35 @@
 if Config.libc == "newlib" then [ build library {
   target = "string",
   cFiles = [
+    "bcmp.c",
     "bcopy.c",
     "bzero.c",
+    "gnu_basename.c",
     "index.c",
+    "memccpy.c",
     "memchr.c",
     "memcmp.c",
     "memcpy.c",
+    "memmem.c",
     "memmove.c",
+    "mempcpy.c",
+    "memrchr.c",
     "memset.c",
+    "rawmemchr.c",
     "rindex.c",
+    "stpcpy.c",
+    "stpncpy.c",
     "strcasecmp.c",
+    "strcasestr.c",
     "strcat.c",
     "strchr.c",
+    "strchrnul.c",
     "strcmp.c",
     "strcoll.c",
     "strcpy.c",
     "strcspn.c",
     "strdup.c",
     "strdup_r.c",
-    "strerror.c",
-    "strerror_r.c",
     "strlcat.c",
     "strlcpy.c",
     "strlen.c",
@@ -29,28 +38,35 @@ if Config.libc == "newlib" then [ build library {
     "strncat.c",
     "strncmp.c",
     "strncpy.c",
+    "strndup.c",
+    "strndup_r.c",
     "strnlen.c",
     "strpbrk.c",
     "strrchr.c",
     "strsep.c",
     "strsignal.c",
     "strspn.c",
+    "strstr.c",
     "strtok.c",
     "strtok_r.c",
     "strupr.c",
     "strxfrm.c",
-    "strstr.c",
     "swab.c",
     "u_strerr.c",
+    "wcpcpy.c",
+    "wcpncpy.c",
+    "wcscasecmp.c",
     "wcscat.c",
     "wcschr.c",
     "wcscmp.c",
     "wcscoll.c",
     "wcscpy.c",
     "wcscspn.c",
+    "wcsdup.c",
     "wcslcat.c",
     "wcslcpy.c",
     "wcslen.c",
+    "wcsncasecmp.c",
     "wcsncat.c",
     "wcsncmp.c",
     "wcsncpy.c",
@@ -68,20 +84,8 @@ if Config.libc == "newlib" then [ build library {
     "wmemcpy.c",
     "wmemmove.c",
     "wmemset.c",
-    "bcmp.c",
-    "memccpy.c",
-    "mempcpy.c",
-    "stpcpy.c",
-    "stpncpy.c",
-    "strndup.c",
-    "strcasestr.c",
-    "strndup_r.c",
-    "wcpcpy.c",
-    "wcpncpy.c",
-    "wcsdup.c",
-    "memmem.c",
-    "wcscasecmp.c",
-    "wcsncasecmp.c"],
+    "xpg_strerror_r.c"
+    ],
   addCFlags = Config.newlibAddCFlags,
   omitCFlags = [ "-Wmissing-prototypes",
                  "-Wmissing-declarations",
index e526d04..e9fd2f5 100644 (file)
@@ -14,10 +14,11 @@ if Config.libc == "newlib" then
     "lcltime.c",
     "lcltime_r.c",
     "mktime.c",
-    "mktm_r.c",
+    "month_lengths.c",
     "strftime.c",
     "strptime.c",
     "time.c",
+    "tzcalc_limits.c",
     "tzlock.c",
     "tzset.c",
     "tzset_r.c",
index 9958a11..9d7211b 100644 (file)
@@ -119,8 +119,3 @@ time(time_t *timer)
     return val;
 #endif
 }
-
-void tzset(void)
-{
-    // XXX: Ignored for now
-}
index 53f83a1..c3165e9 100644 (file)
@@ -445,17 +445,19 @@ struct winsize {
 #endif
 
 #ifndef TIMEVAL_TO_TIMESPEC
-#define        TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
+#define        TIMEVAL_TO_TIMESPEC(tv, ts)  \
+do {                                   \
        (ts)->tv_sec = (tv)->tv_sec;                                    \
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
-}
+} while(0)
 #endif
 
 #ifndef TIMESPEC_TO_TIMEVAL
-#define        TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
+#define        TIMESPEC_TO_TIMEVAL(tv, ts) \
+do {                                   \
        (tv)->tv_sec = (ts)->tv_sec;                                    \
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
-}
+} while(0)
 #endif
 
 #ifndef __P
index 3ef373f..9c1fe74 100644 (file)
@@ -138,10 +138,10 @@ int truncate(const char *path, off_t length)
 int nanosleep(const struct timespec *req, struct timespec *rem)
 {
        int rc, saverrno;
-       extern int errno;
+       //extern int errno;
        struct timeval tstart, tstop, tremain, time2wait;
 
-       TIMESPEC_TO_TIMEVAL(&time2wait, req)
+       TIMESPEC_TO_TIMEVAL(&time2wait, req);
        (void) gettimeofday(&tstart, NULL);
        rc = select(0, NULL, NULL, NULL, &time2wait);
        if (rc == -1) {
@@ -158,8 +158,9 @@ int nanosleep(const struct timespec *req, struct timespec *rem)
                tremain.tv_sec = 0;
                tremain.tv_usec = 0;
        }
-       if (rem != NULL)
-               TIMEVAL_TO_TIMESPEC(&tremain, rem)
+       if (rem != NULL) {
+               TIMEVAL_TO_TIMESPEC(&tremain, rem);
+        }
 
        return(rc);
 }
index f5d3483..fcfa953 100644 (file)
@@ -280,22 +280,6 @@ static errval_t append_to_file(struct dirent *f, const char *str)
     return SYS_ERR_OK;
 }
 
-/* maybe this should be in libc -- apparently it's a GNU extension */
-static void *memrchr(const void *p, int c, size_t n)
-{
-    const char *s = &((const char *)p)[n - 1];
-
-    while (n--) {
-        if (*s == c) {
-            return (void *) s;
-        }
-        s--;
-    }
-
-    return NULL;
-}
-
-
 // try to remove the 'irrelevant' prefix of a multiboot path
 // eg. "/username/blerg/x86_64/sbin/foo..." becomes "/x86_64/sbin/foo..."
 static const char *remove_prefix(const char *path)