]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StdLib: Fix compiler compatibility issues:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Feb 2012 00:17:05 +0000 (00:17 +0000)
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Feb 2012 00:17:05 +0000 (00:17 +0000)
tcp.h:    Fix packed structure syntax.  cdefs.h is not included so the existing __packed attribute was not properly expanded.  Non-GCC compilers were also not handled correctly.  Changing to the pack(n) pragma is compatible between all supported compilers.

SysCalls.c:  The utimes() function has a fixed number of arguments and calls a function that takes a va_list argument.  GCC will not allow the va_start, etc., macros to be used in a function with a fixed number of arguments, even though that is valid C.  The workaround was to create a worker function for utimes() that takes a variable number of arguments.  The worker function then uses the va_* macros.

Signed-off-by: darylm503
Reviewed-by: leegrosenbaum
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12977 6f19259b-4bc3-4df7-8a09-765794883524

StdLib/Include/netinet/tcp.h
StdLib/LibC/Uefi/SysCalls.c

index 8bb8f61ec925fd0267b666ae1d6521c83092e1ff..31948a6a706600aff8048b13f2b854ab9e4730f3 100644 (file)
@@ -1,8 +1,17 @@
-/*     $NetBSD: tcp.h,v 1.28 2007/12/25 18:33:47 perry Exp $   */\r
+/** @file\r
+    Declarations for TCP.\r
+\r
+    Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+    This program and the accompanying materials are licensed and made available under\r
+    the terms and conditions of the BSD License that accompanies this distribution.\r
+    The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-/*\r
  * Copyright (c) 1982, 1986, 1993\r
- *     The Regents of the University of California.  All rights reserved.\r
+ *  The Regents of the University of California.  All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or without\r
  * modification, are permitted provided that the following conditions\r
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
  * SUCH DAMAGE.\r
  *\r
- *     @(#)tcp.h       8.1 (Berkeley) 6/10/93\r
+ *  @(#)tcp.h 8.1 (Berkeley) 6/10/93\r
+    NetBSD: tcp.h,v 1.28 2007/12/25 18:33:47 perry Exp\r
  */\r
-\r
 #ifndef _NETINET_TCP_H_\r
 #define _NETINET_TCP_H_\r
 \r
 #include <sys/featuretest.h>\r
 \r
-#if defined(_NETBSD_SOURCE)\r
-\r
 typedef u_int32_t tcp_seq;\r
+\r
+/* Flag definitions for tcphdr.th_flags */\r
+#define TH_FIN    0x01\r
+#define TH_SYN    0x02\r
+#define TH_RST    0x04\r
+#define TH_PUSH   0x08\r
+#define TH_ACK    0x10\r
+#define TH_URG    0x20\r
+#define TH_ECE    0x40\r
+#define TH_CWR    0x80\r
+\r
+#pragma pack(1)\r
 /*\r
  * TCP header.\r
  * Per RFC 793, September, 1981.\r
  * Updated by RFC 3168, September, 2001.\r
  */\r
 struct tcphdr {\r
-       u_int16_t th_sport;             /* source port */\r
-       u_int16_t th_dport;             /* destination port */\r
-       tcp_seq   th_seq;               /* sequence number */\r
-       tcp_seq   th_ack;               /* acknowledgement number */\r
+  u_int16_t th_sport;   /* source port */\r
+  u_int16_t th_dport;   /* destination port */\r
+  tcp_seq   th_seq;     /* sequence number */\r
+  tcp_seq   th_ack;     /* acknowledgement number */\r
 #if BYTE_ORDER == LITTLE_ENDIAN\r
-       /*LINTED non-portable bitfields*/\r
-       u_int8_t  th_x2:4,              /* (unused) */\r
-                 th_off:4;             /* data offset */\r
+  /*LINTED non-portable bitfields*/\r
+  u_int8_t  th_x2:4,    /* (unused) */\r
+            th_off:4;   /* data offset */\r
 #endif\r
 #if BYTE_ORDER == BIG_ENDIAN\r
-       /*LINTED non-portable bitfields*/\r
-       u_int8_t  th_off:4,             /* data offset */\r
-                 th_x2:4;              /* (unused) */\r
+  /*LINTED non-portable bitfields*/\r
+  u_int8_t  th_off:4,   /* data offset */\r
+            th_x2:4;    /* (unused) */\r
 #endif\r
-       u_int8_t  th_flags;\r
-#define        TH_FIN    0x01\r
-#define        TH_SYN    0x02\r
-#define        TH_RST    0x04\r
-#define        TH_PUSH   0x08\r
-#define        TH_ACK    0x10\r
-#define        TH_URG    0x20\r
-#define        TH_ECE    0x40\r
-#define        TH_CWR    0x80\r
-       u_int16_t th_win;                       /* window */\r
-       u_int16_t th_sum;                       /* checksum */\r
-       u_int16_t th_urp;                       /* urgent pointer */\r
-} __packed;\r
-\r
-#define        TCPOPT_EOL              0\r
-#define        TCPOPT_NOP              1\r
-#define        TCPOPT_MAXSEG           2\r
-#define           TCPOLEN_MAXSEG               4\r
-#define        TCPOPT_WINDOW           3\r
-#define           TCPOLEN_WINDOW               3\r
-#define        TCPOPT_SACK_PERMITTED   4               /* Experimental */\r
-#define           TCPOLEN_SACK_PERMITTED       2\r
-#define        TCPOPT_SACK             5               /* Experimental */\r
-#define        TCPOPT_TIMESTAMP        8\r
-#define           TCPOLEN_TIMESTAMP            10\r
-#define           TCPOLEN_TSTAMP_APPA          (TCPOLEN_TIMESTAMP+2) /* appendix A */\r
-\r
-#define TCPOPT_TSTAMP_HDR      \\r
+  u_int8_t  th_flags;\r
+  u_int16_t th_win;     /* window */\r
+  u_int16_t th_sum;     /* checksum */\r
+  u_int16_t th_urp;     /* urgent pointer */\r
+};\r
+#pragma pack()\r
+\r
+#define TCPOPT_EOL              0\r
+#define TCPOPT_NOP              1\r
+#define TCPOPT_MAXSEG           2\r
+#define TCPOLEN_MAXSEG          4\r
+#define TCPOPT_WINDOW           3\r
+#define TCPOLEN_WINDOW          3\r
+#define TCPOPT_SACK_PERMITTED   4     /* Experimental */\r
+#define TCPOLEN_SACK_PERMITTED  2\r
+#define TCPOPT_SACK             5     /* Experimental */\r
+#define TCPOPT_TIMESTAMP        8\r
+#define TCPOLEN_TIMESTAMP       10\r
+#define TCPOLEN_TSTAMP_APPA     (TCPOLEN_TIMESTAMP+2) /* appendix A */\r
+\r
+#define TCPOPT_TSTAMP_HDR \\r
     (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)\r
 \r
-#define        TCPOPT_SIGNATURE        19              /* Keyed MD5: RFC 2385 */\r
-#define           TCPOLEN_SIGNATURE            18\r
-#define    TCPOLEN_SIGLEN              (TCPOLEN_SIGNATURE+2) /* padding */\r
+#define TCPOPT_SIGNATURE        19    /* Keyed MD5: RFC 2385 */\r
+#define TCPOLEN_SIGNATURE       18\r
+#define TCPOLEN_SIGLEN          (TCPOLEN_SIGNATURE+2) /* padding */\r
 \r
-#define MAX_TCPOPTLEN  40      /* max # bytes that go in options */\r
+#define MAX_TCPOPTLEN           40    /* max # bytes that go in options */\r
 \r
-/*\r
- * Default maximum segment size for TCP.\r
- * This is defined by RFC 1112 Sec 4.2.2.6.\r
+/*  Default maximum segment size for TCP.\r
+ *  This is defined by RFC 1112 Sec 4.2.2.6.\r
  */\r
-#define        TCP_MSS         536\r
+#define TCP_MSS                 536\r
 \r
-#define        TCP_MINMSS      216\r
+#define TCP_MINMSS              216\r
 \r
-#define        TCP_MAXWIN      65535   /* largest value for (unscaled) window */\r
+#define TCP_MAXWIN            65535   /* largest value for (unscaled) window */\r
 \r
-#define        TCP_MAX_WINSHIFT        14      /* maximum window shift */\r
+#define TCP_MAX_WINSHIFT         14   /* maximum window shift */\r
 \r
-#define        TCP_MAXBURST    4       /* maximum segments in a burst */\r
+#define TCP_MAXBURST              4   /* maximum segments in a burst */\r
 \r
-#endif /* _NETBSD_SOURCE */\r
+/*  User-settable options (used with setsockopt). */\r
+#define TCP_NODELAY               1   /* don't delay send to coalesce packets */\r
+#define TCP_MAXSEG                2   /* set maximum segment size */\r
+#define TCP_KEEPIDLE              3\r
 \r
-/*\r
- * User-settable options (used with setsockopt).\r
- */\r
-#define        TCP_NODELAY     1       /* don't delay send to coalesce packets */\r
-#define        TCP_MAXSEG      2       /* set maximum segment size */\r
-#define        TCP_KEEPIDLE    3\r
 #ifdef notyet\r
-#define        TCP_NOPUSH      4       /* reserved for FreeBSD compat */\r
+#define TCP_NOPUSH                4   /* reserved for FreeBSD compat */\r
 #endif\r
-#define        TCP_KEEPINTVL   5\r
-#define        TCP_KEEPCNT     6\r
-#define        TCP_KEEPINIT    7\r
+\r
+#define TCP_KEEPINTVL             5\r
+#define TCP_KEEPCNT               6\r
+#define TCP_KEEPINIT              7\r
+\r
 #ifdef notyet\r
-#define        TCP_NOOPT       8       /* reserved for FreeBSD compat */\r
+#define TCP_NOOPT                 8   /* reserved for FreeBSD compat */\r
 #endif\r
-#define        TCP_MD5SIG      0x10    /* use MD5 digests (RFC2385) */\r
-#define        TCP_CONGCTL     0x20    /* selected congestion control */\r
+\r
+#define TCP_MD5SIG              0x10  /* use MD5 digests (RFC2385) */\r
+#define TCP_CONGCTL             0x20  /* selected congestion control */\r
 \r
 #endif /* !_NETINET_TCP_H_ */\r
index 90d7277f86cdc852af5808336c82e2f738d4454c..ebae38f3fbfa5b184bb27926cfd8d2e1e5ab584b 100644 (file)
@@ -190,11 +190,11 @@ _closeX  (int fd, int NewState)
     if(Fp->RefCount == 1) { // There should be no other users\r
     if(! IsDupFd(fd)) {\r
       // Only do the close if no one else is using the FileHandle\r
-        if(Fp->f_iflags & FIF_DELCLOSE) {\r
-          /* Handle files marked "Delete on Close". */\r
-          if(Fp->f_ops->fo_delete != NULL) {\r
-            retval = Fp->f_ops->fo_delete(Fp);\r
-          }\r
+      if(Fp->f_iflags & FIF_DELCLOSE) {\r
+        /* Handle files marked "Delete on Close". */\r
+        if(Fp->f_ops->fo_delete != NULL) {\r
+          retval = Fp->f_ops->fo_delete(Fp);\r
+        }\r
       }\r
       else {\r
           retval = Fp->f_ops->fo_close( Fp);\r
@@ -875,7 +875,7 @@ rmdir(
     retval = filp->f_ops->fo_rmdir(filp);\r
     filp->f_iflags = 0;           // Close this FD\r
     filp->RefCount = 0;           // No one using this FD\r
-      }\r
+  }\r
   return retval;\r
 }\r
 \r
@@ -990,8 +990,8 @@ ioctl(
     }\r
     else {\r
       /* All other requests. */\r
-    retval = filp->f_ops->fo_ioctl(filp, request, argp);\r
-  }\r
+      retval = filp->f_ops->fo_ioctl(filp, request, argp);\r
+    }\r
   }\r
   else {\r
     errno   =  EBADF;\r
@@ -1195,25 +1195,25 @@ chdir (const char *path)
 \r
   /* Old Shell does not support Set Current Dir. */\r
   if(gEfiShellProtocol != NULL) {\r
-  Cwd = ShellGetCurrentDir(NULL);\r
-  if (Cwd != NULL) {\r
-    /* We have shell support */\r
-    UnicodePath = AllocatePool(((AsciiStrLen (path) + 1) * sizeof (CHAR16)));\r
-    if (UnicodePath == NULL) {\r
-      errno = ENOMEM;\r
-      return -1;\r
-    }\r
-    AsciiStrToUnicodeStr(path, UnicodePath);\r
-    Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);\r
-    FreePool(UnicodePath);\r
-    if (EFI_ERROR(Status)) {\r
+    Cwd = ShellGetCurrentDir(NULL);\r
+    if (Cwd != NULL) {\r
+      /* We have shell support */\r
+      UnicodePath = AllocatePool(((AsciiStrLen (path) + 1) * sizeof (CHAR16)));\r
+      if (UnicodePath == NULL) {\r
+        errno = ENOMEM;\r
+        return -1;\r
+      }\r
+      AsciiStrToUnicodeStr(path, UnicodePath);\r
+      Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);\r
+      FreePool(UnicodePath);\r
+      if (EFI_ERROR(Status)) {\r
         errno = ENOENT;\r
-      return -1;\r
-    } else {\r
-      return 0;\r
+        return -1;\r
+      } else {\r
+        return 0;\r
+      }\r
     }\r
   }\r
-  }\r
   /* Add here for non-shell */\r
   errno = EPERM;\r
   return -1;\r
@@ -1229,17 +1229,16 @@ pid_t getpgrp(void)
   return ((pid_t)(UINTN)(gImageHandle));\r
 }\r
 \r
-/** Set file access and modification times.\r
-\r
-    @param[in]  path\r
-    @param[in]  times\r
-\r
-    @return\r
-**/\r
+/* Internal worker function for utimes.\r
+    This works around an error produced by GCC when the va_* macros\r
+    are used within a function with a fixed number of arguments.\r
+*/\r
+static\r
 int\r
-utimes(\r
-  const char *path,\r
-  const struct timeval *times\r
+EFIAPI\r
+va_Utimes(\r
+  const char   *path,\r
+  ...\r
   )\r
 {\r
   struct __filedes   *filp;\r
@@ -1256,6 +1255,21 @@ utimes(
   }\r
   va_end(ap);\r
   return retval;\r
+}\r
+\r
+/** Set file access and modification times.\r
 \r
+    @param[in]  path\r
+    @param[in]  times\r
+\r
+    @return\r
+**/\r
+int\r
+utimes(\r
+  const char *path,\r
+  const struct timeval *times\r
+  )\r
+{\r
+  return va_Utimes(path, times);\r
 }\r
 \r