[En-Nut-Discussion] Compiling with GCC4

Harald Kipp harald.kipp at egnite.de
Tue Mar 7 19:35:09 CET 2006


Hi,

IMHO this is the most minimal patch to get Nut/OS compiling with GCC 4.0.
So far tested for ARM only, but AVR should work too.

In order to avoid breaking BTNut, I'll wait for their OK before
applying it to CVS HEAD.

Harald


diff -ruN nut/arch/arm/os/context.c nut-gcc4/arch/arm/os/context.c
--- nut/arch/arm/os/context.c	2005-10-24 12:09:41.000000000 +0200
+++ nut-gcc4/arch/arm/os/context.c	2006-03-07 19:15:19.000000000 +0100
@@ -192,7 +192,7 @@
   * \return Pointer to the NUTTHREADINFO structure or 0 to indicate an
   *         error.
   */
-HANDLE NutThreadCreate(u_char * name, void (*fn) (void *), void *arg, 
size_t stackSize)
+HANDLE NutThreadCreate(char * name, void (*fn) (void *), void *arg, size_t 
stackSize)
  {
      u_char *threadMem;
      SWITCHFRAME *sf;
diff -ruN nut/arch/avr/os/context_gcc.c nut-gcc4/arch/avr/os/context_gcc.c
--- nut/arch/avr/os/context_gcc.c	2005-10-04 08:17:15.000000000 +0200
+++ nut-gcc4/arch/avr/os/context_gcc.c	2006-03-07 19:15:44.000000000 +0100
@@ -274,7 +274,7 @@
   * \return Pointer to the NUTTHREADINFO structure or 0 to indicate an
   *         error.
   */
-HANDLE NutThreadCreate(u_char * name, void (*fn) (void *), void *arg, 
size_t stackSize)
+HANDLE NutThreadCreate(char * name, void (*fn) (void *), void *arg, size_t 
stackSize)
  {
      u_char *threadMem;
      SWITCHFRAME *sf;
diff -ruN nut/crt/open.c nut-gcc4/crt/open.c
--- nut/crt/open.c	2004-03-16 17:48:27.000000000 +0100
+++ nut-gcc4/crt/open.c	2006-03-07 18:53:37.000000000 +0100
@@ -79,7 +79,7 @@
  int _open(CONST char *name, int mode)
  {
      NUTDEVICE *dev;
-    u_char dev_name[9];
+    char dev_name[9];
      u_char nidx;
      CONST char *nptr = name;

diff -ruN nut/fs/dirent.c nut-gcc4/fs/dirent.c
--- nut/fs/dirent.c	2006-01-05 17:45:20.000000000 +0100
+++ nut-gcc4/fs/dirent.c	2006-03-07 18:54:01.000000000 +0100
@@ -113,7 +113,7 @@
  {
      DIR *dir = 0;
      NUTDEVICE *dev;
-    u_char dev_name[9];
+    char dev_name[9];
      u_char nidx;
      CONST char *nptr = name;

diff -ruN nut/fs/pathops.c nut-gcc4/fs/pathops.c
--- nut/fs/pathops.c	2006-01-05 17:52:23.000000000 +0100
+++ nut-gcc4/fs/pathops.c	2006-03-07 18:54:30.000000000 +0100
@@ -66,7 +66,7 @@
  static int PathOperation(CONST char *path, int opcode)
  {
      NUTDEVICE *dev;
-    u_char dev_name[9];
+    char dev_name[9];
      u_char nidx;
      CONST char *nptr = path;

@@ -156,7 +156,7 @@
  int stat(CONST char *path, struct stat *s)
  {
      NUTDEVICE *dev;
-    u_char dev_name[9];
+    char dev_name[9];
      u_char nidx;
      CONST char *nptr = path;
      FSCP_STATUS parms;
diff -ruN nut/include/arch/arm.h nut-gcc4/include/arch/arm.h
--- nut/include/arch/arm.h	2006-03-02 21:02:05.000000000 +0100
+++ nut-gcc4/include/arch/arm.h	2006-03-07 18:56:28.000000000 +0100
@@ -107,13 +107,13 @@

  #define main       NutAppMain

-#define strlen_P(x)             strlen(x)
-#define strcpy_P(x,y)           strcpy(x,y)
+#define strlen_P(x)             strlen((char *)(x))
+#define strcpy_P(x,y)           strcpy(x,(char *)(y))

-#define strcmp_P(x, y)          strcmp(x, y)
+#define strcmp_P(x, y)          strcmp((char *)(x), (char *)(y))
  #define memcpy_P(x, y, z)       memcpy(x, y, z)

-#define fputs_P(x, y)           fputs(x, y)
+#define fputs_P(x, y)           fputs((char *)(x), y)
  #define fprintf_P               fprintf
  #define printf_P                printf

diff -ruN nut/include/arpa/inet.h nut-gcc4/include/arpa/inet.h
--- nut/include/arpa/inet.h	2003-05-09 17:41:03.000000000 +0200
+++ nut-gcc4/include/arpa/inet.h	2006-03-07 18:57:05.000000000 +0100
@@ -61,8 +61,8 @@
   * \file arpa/inet.h
   * \brief Internet address conversion.
   */
-extern u_long inet_addr(CONST  u_char *str);
-extern u_char *inet_ntoa(u_long addr);
+extern u_long inet_addr(CONST char *str);
+extern char *inet_ntoa(u_long addr);

  __END_DECLS

diff -ruN nut/include/dev/chat.h nut-gcc4/include/dev/chat.h
--- nut/include/dev/chat.h	2005-04-30 19:42:41.000000000 +0200
+++ nut-gcc4/include/dev/chat.h	2006-03-07 18:57:40.000000000 +0100
@@ -98,9 +98,9 @@
      int chat_fd;
      u_char chat_arg;
      u_char chat_aborts;
-    u_char *chat_abort[CHAT_MAX_ABORTS];
+    char *chat_abort[CHAT_MAX_ABORTS];
      u_char chat_abomat[CHAT_MAX_ABORTS];
-    u_char *chat_report_search;
+    char *chat_report_search;
      u_char chat_repmat;
      char chat_report_state;
  } NUTCHAT;
diff -ruN nut/include/net/netdebug.h nut-gcc4/include/net/netdebug.h
--- nut/include/net/netdebug.h	2003-05-09 17:41:12.000000000 +0200
+++ nut-gcc4/include/net/netdebug.h	2006-03-07 18:58:08.000000000 +0100
@@ -73,7 +73,7 @@
  extern void NutTracePPP(FILE *stream, u_char flags);

  extern void NutDumpTcpHeader(FILE *stream, u_char *ds, TCPSOCKET *sock, 
NETBUF *nb);
-extern void NutDumpSockState(FILE *stream, u_char state, u_char *lead, 
u_char *trail);
+extern void NutDumpSockState(FILE *stream, u_char state, char *lead, char 
*trail);
  extern void NutDumpSocketList(FILE *stream);

  extern void NutDumpLcpOption(FILE * stream, NETBUF * nb);
diff -ruN nut/include/pro/httpd.h nut-gcc4/include/pro/httpd.h
--- nut/include/pro/httpd.h	2005-08-26 17:12:39.000000000 +0200
+++ nut-gcc4/include/pro/httpd.h	2006-03-07 18:59:01.000000000 +0100
@@ -94,7 +94,7 @@
  extern void NutHttpSendError(FILE * stream, REQUEST * req, int status);
  extern char *NutGetMimeType(char *name);
  extern void *NutGetMimeHandler(char *name);
-extern u_char NutSetMimeHandler(char *extension, void (*handler)(FILE 
*stream, int fd, int file_len, u_char *http_root, REQUEST *req));
+extern u_char NutSetMimeHandler(char *extension, void (*handler)(FILE 
*stream, int fd, int file_len, char *http_root, REQUEST *req));

  __END_DECLS

diff -ruN nut/include/pro/wins.h nut-gcc4/include/pro/wins.h
--- nut/include/pro/wins.h	2005-02-05 21:38:51.000000000 +0100
+++ nut-gcc4/include/pro/wins.h	2006-03-07 18:59:20.000000000 +0100
@@ -51,7 +51,7 @@

  __BEGIN_DECLS
  /* Function prototypes. */
-extern int NutWinsNameQuery(u_char * name, u_long ipaddr);
+extern int NutWinsNameQuery(char * name, u_long ipaddr);

  __END_DECLS
  /* */
diff -ruN nut/include/sys/confnet.h nut-gcc4/include/sys/confnet.h
--- nut/include/sys/confnet.h	2006-01-23 18:34:29.000000000 +0100
+++ nut-gcc4/include/sys/confnet.h	2006-03-07 19:16:22.000000000 +0100
@@ -75,8 +75,8 @@
   */
  struct __attribute__ ((packed)) _CONFNET {
      u_char cd_size;         /*!< \brief Size of this structure. */
-    u_char cd_name[9];      /*!< \brief Magic cookie. */
-    u_char cdn_mac[6];      /*!< \brief Ethernet MAC address. */
+    char cd_name[9];      /*!< \brief Magic cookie. */
+    u_char cdn_mac[6];        /*!< \brief Ethernet MAC address. */
      u_long cdn_ip_addr;     /*!< \brief Last used IP address. */
      u_long cdn_ip_mask;     /*!< \brief IP netmask. */
      u_long cdn_gateway;     /*!< \brief Default route. */
diff -ruN nut/include/sys/confos.h nut-gcc4/include/sys/confos.h
--- nut/include/sys/confos.h	2006-01-23 18:34:29.000000000 +0100
+++ nut-gcc4/include/sys/confos.h	2006-03-07 19:00:06.000000000 +0100
@@ -82,7 +82,7 @@
  struct __attribute__ ((packed)) _CONFOS {
      u_char size;            /*!< \brief Size of this structure. */
      u_char magic[2];        /*!< \brief Magic cookie. */
-    u_char hostname[16];    /*!< \brief host name of the system. */
+    char hostname[16];      /*!< \brief host name of the system. */
  };

  extern CONFOS confos;
diff -ruN nut/include/sys/device.h nut-gcc4/include/sys/device.h
--- nut/include/sys/device.h	2006-01-05 17:45:34.000000000 +0100
+++ nut-gcc4/include/sys/device.h	2006-03-07 19:00:36.000000000 +0100
@@ -154,7 +154,7 @@
      /*!
       * \brief Unique device name.
       */
-    u_char dev_name[9];
+    char dev_name[9];

      /*!
       * \brief Type of interface.
diff -ruN nut/include/sys/thread.h nut-gcc4/include/sys/thread.h
--- nut/include/sys/thread.h	2005-10-08 00:48:25.000000000 +0200
+++ nut-gcc4/include/sys/thread.h	2006-03-07 19:01:31.000000000 +0100
@@ -128,7 +128,7 @@
      struct _NUTTHREADINFO {
          NUTTHREADINFO *volatile td_next;        /*!< \brief Linked list 
of all threads. */
          NUTTHREADINFO *td_qnxt; /*!< \brief Linked list of all queued 
thread. */
-        u_char td_name[9];      /*!< \brief Name of this thread. */
+        char td_name[9];        /*!< \brief Name of this thread. */
          u_char td_state;        /*!< \brief Operating state. One of TDS_ */
          uptr_t td_sp;           /*!< \brief Stack pointer. */
          u_char td_priority;     /*!< \brief Priority level. 0 is highest 
priority. */
@@ -171,7 +171,7 @@
      extern void NutThreadSetSleepMode(u_char mode);
  #endif

-    extern HANDLE NutThreadCreate(u_char * name, void (*fn) (void *), void 
*arg, size_t stackSize);
+    extern HANDLE NutThreadCreate(char * name, void (*fn) (void *), void 
*arg, size_t stackSize);
      extern u_char NutThreadSetPriority(u_char level);

      extern void NutThreadKill(void);
@@ -186,7 +186,7 @@
      extern void NutThreadRemoveQueue(NUTTHREADINFO * td, NUTTHREADINFO * 
volatile *tqpp);

      extern void NutThreadSwitch(void);
-    extern HANDLE GetThreadByName(u_char * name);
+    extern HANDLE GetThreadByName(char * name);

  /*!
   * \brief Macro for thread entry definitions.
diff -ruN nut/net/inet.c nut-gcc4/net/inet.c
--- nut/net/inet.c	2005-08-02 20:47:03.000000000 +0200
+++ nut-gcc4/net/inet.c	2006-03-07 19:02:24.000000000 +0100
@@ -121,7 +121,7 @@
   *
   * \return IP address in network byte order.
   */
-u_long inet_addr(CONST u_char * str)
+u_long inet_addr(CONST char * str)
  {
      u_short num;
      u_long addr = 0;
@@ -165,11 +165,11 @@
   * \return Pointer to a static buffer containing the
   *         ASCII representation.
   */
-u_char *inet_ntoa(u_long addr)
+char *inet_ntoa(u_long addr)
  {
-    static u_char str[16];
-    u_char inv[3];
-    u_char *rp;
+    static char str[16];
+    char inv[3];
+    char *rp;
      u_char *ap;
      u_char rem;
      u_char n;
diff -ruN nut/net/netdebug.c nut-gcc4/net/netdebug.c
--- nut/net/netdebug.c	2005-01-13 19:48:53.000000000 +0100
+++ nut-gcc4/net/netdebug.c	2006-03-07 19:02:50.000000000 +0100
@@ -101,7 +101,7 @@
      fputs("\n", stream);
  }

-void NutDumpSockState(FILE * stream, u_char state, u_char * lead, u_char * 
trail)
+void NutDumpSockState(FILE * stream, u_char state, char * lead, char * trail)
  {
      if (lead)
          fputs(lead, stream);
diff -ruN nut/os/thread.c nut-gcc4/os/thread.c
--- nut/os/thread.c	2006-02-08 16:20:56.000000000 +0100
+++ nut-gcc4/os/thread.c	2006-03-07 19:03:19.000000000 +0100
@@ -564,7 +564,7 @@
      killedThread = runningThread;
  }

-HANDLE GetThreadByName(u_char * name)
+HANDLE GetThreadByName(char * name)
  {
      NUTTHREADINFO *tdp;

diff -ruN nut/pro/asp.c nut-gcc4/pro/asp.c
--- nut/pro/asp.c	2005-08-10 12:26:38.000000000 +0200
+++ nut-gcc4/pro/asp.c	2006-03-07 19:04:21.000000000 +0100
@@ -140,7 +140,7 @@
  /************************************************************/
  /*  NutHttpCheckAsp                                         */
  /************************************************************/
-void NutHttpProcessAsp(FILE * stream, int fd, int file_len, u_char* 
http_root, REQUEST *req)
+void NutHttpProcessAsp(FILE * stream, int fd, int file_len, char* 
http_root, REQUEST *req)
  {
      int n;
      char *pReadBuffer = NULL;
diff -ruN nut/pro/dencode.c nut-gcc4/pro/dencode.c
--- nut/pro/dencode.c	2004-03-16 17:48:46.000000000 +0100
+++ nut-gcc4/pro/dencode.c	2006-03-07 19:04:46.000000000 +0100
@@ -91,7 +91,7 @@
   * be at most 3/4 the size of the encoded, and may be smaller if there
   * are padding characters (blanks, newlines).
   */
-char *NutDecodeBase64(u_char * str)
+char *NutDecodeBase64(char * str)
  {
      /* bug fix from Damian Slee. */
      char code;
diff -ruN nut/pro/dencode.h nut-gcc4/pro/dencode.h
--- nut/pro/dencode.h	2003-05-09 17:41:56.000000000 +0200
+++ nut-gcc4/pro/dencode.h	2006-03-07 19:05:04.000000000 +0100
@@ -3,7 +3,7 @@

  #include <sys/types.h>

-extern char *NutDecodeBase64(u_char *str);
+extern char *NutDecodeBase64(char *str);
  extern int NutDecodeHex(char c);
  extern char *NutDecodePath(char *path);

diff -ruN nut/pro/ftpd.c nut-gcc4/pro/ftpd.c
--- nut/pro/ftpd.c	2006-02-23 16:48:08.000000000 +0100
+++ nut-gcc4/pro/ftpd.c	2006-03-07 19:17:05.000000000 +0100
@@ -160,7 +160,7 @@
   *             Trailing carriage return or linefeed characters are
   *             cut off.
   */
-static void SplitCmdArg(u_char * line, u_char ** cmd, u_char ** args)
+static void SplitCmdArg(char * line, char ** cmd, char ** args)
  {
      /* Skip leading spaces. */
      while (*line && *line <= ' ') {
@@ -211,7 +211,7 @@
   *
   * \return The number of converted byte values. Should be 6.
   */
-static int ParseIpPort(CONST u_char * arg, u_long * ip, u_short * port)
+static int ParseIpPort(CONST char * arg, u_long * ip, u_short * port)
  {
      int rc;

@@ -1040,8 +1040,8 @@
  int NutFtpProcessRequest(FTPSESSION * session, char *request)
  {
      int rc = 0;
-    u_char *cmd;
-    u_char *args;
+    char *cmd;
+    char *args;

      /* Split the line into command and argument part. */
      SplitCmdArg(request, &cmd, &args);
diff -ruN nut/pro/httpd.c nut-gcc4/pro/httpd.c
--- nut/pro/httpd.c	2006-01-06 10:19:42.000000000 +0100
+++ nut-gcc4/pro/httpd.c	2006-03-07 19:08:19.000000000 +0100
@@ -110,7 +110,7 @@
  static struct {
      char *ext;
      char *type;
-    void (*handler)(FILE *stream, int fd, int file_len, u_char *http_root, 
REQUEST *req);
+    void (*handler)(FILE *stream, int fd, int file_len, char *http_root, 
REQUEST *req);
  } mimeTypes[] = {
      {
      ".txt", "text/plain", NULL}, {
@@ -303,7 +303,7 @@
   * \return 1 on error or 0 on success
   */

-u_char NutSetMimeHandler(char *extension, void (*handler)(FILE *stream, 
int fd, int file_len, u_char *http_root, REQUEST *req))
+u_char NutSetMimeHandler(char *extension, void (*handler)(FILE *stream, 
int fd, int file_len, char *http_root, REQUEST *req))
  {
      size_t i;

@@ -589,7 +589,7 @@
      int size;
      long file_len;
      char *filename = NULL;
-    void (*handler)(FILE *stream, int fd, int file_len, u_char *http_root, 
REQUEST *req);
+    void (*handler)(FILE *stream, int fd, int file_len, char *http_root, 
REQUEST *req);

      /*
       * Validate authorization.
@@ -625,7 +625,7 @@
      fd = _open(filename, _O_BINARY | _O_RDONLY);
      NutHeapFree(filename);
      if (fd == -1) {                     // Search for index.html
-        u_char *index;
+        char *index;
          u_short urll;


diff -ruN nut/pro/resolv.c nut-gcc4/pro/resolv.c
--- nut/pro/resolv.c	2006-01-23 20:52:10.000000000 +0100
+++ nut-gcc4/pro/resolv.c	2006-03-07 19:18:50.000000000 +0100
@@ -164,7 +164,7 @@
  static u_short AddName(u_char * cp, CONST u_char * name)
  {
      u_char *lcp;
-    u_short rc = strlen(name) + 2;
+    u_short rc = strlen((char *)name) + 2;

      lcp = cp++;
      *lcp = 0;
@@ -218,7 +218,7 @@
      if ((*cp & 0xC0) == 0xC0)
          return 2;

-    rc = strlen(cp) + 1;
+    rc = strlen((char *)cp) + 1;
      np = *npp = NutHeapAlloc(rc);
      len = *cp++;
      while (len) {
@@ -295,8 +295,8 @@
      if (doq) {
          if (doq->doq_name)
              NutHeapFree(doq->doq_name);
-        doq->doq_name = NutHeapAlloc(strlen(name) + 1);
-        strcpy(doq->doq_name, name);
+        doq->doq_name = NutHeapAlloc(strlen((char *)name) + 1);
+        strcpy((char *)doq->doq_name, (char *)name);
          doq->doq_type = type;
          doq->doq_class = 1;
      }
@@ -385,12 +385,12 @@
          doc.doc_domain = 0;
      }
      if (hostname) {
-        doc.doc_hostname = NutHeapAlloc(strlen(hostname) + 1);
-        strcpy(doc.doc_hostname, hostname);
+        doc.doc_hostname = NutHeapAlloc(strlen((char *)hostname) + 1);
+        strcpy((char *)doc.doc_hostname, (char *)hostname);
      }
      if (domain) {
-        doc.doc_domain = NutHeapAlloc(strlen(domain) + 1);
-        strcpy(doc.doc_domain, domain);
+        doc.doc_domain = NutHeapAlloc(strlen((char *)domain) + 1);
+        strcpy((char *)doc.doc_domain, (char *)domain);
      }
      doc.doc_ip1 = pdnsip;
      doc.doc_ip2 = sdnsip;
diff -ruN nut/pro/ssi.c nut-gcc4/pro/ssi.c
--- nut/pro/ssi.c	2005-08-05 14:22:14.000000000 +0200
+++ nut-gcc4/pro/ssi.c	2006-03-07 19:20:05.000000000 +0100
@@ -81,7 +81,7 @@
   * \param filename Name of the included file. e.g."UROM:test.txt"
   */

-static void NutSsiProcessFile(FILE * stream, u_char *filename)
+static void NutSsiProcessFile(FILE * stream, char *filename)
  {
      int fd;
      int n;
@@ -147,7 +147,7 @@
   * \param orig_req The http request struct of the top most http_request
   */

-static void NutSsiProcessVirtual(FILE * stream, u_char *url, u_char* 
http_root, REQUEST *orig_req)
+static void NutSsiProcessVirtual(FILE * stream, char *url, char* 
http_root, REQUEST *orig_req)
  {
      int fd;
      int n;
@@ -155,7 +155,7 @@
      int size;
      long file_len;
      char *filename = NULL;
-    void (*handler)(FILE *stream, int fd, int file_len, u_char *http_root, 
REQUEST *req);
+    void (*handler)(FILE *stream, int fd, int file_len, char *http_root, 
REQUEST *req);


      char *cp;
@@ -235,7 +235,7 @@
      fd = _open(filename, _O_BINARY | _O_RDONLY);
      NutHeapFree(filename);
      if (fd == -1) {                     // Search for index.html
-        u_char *index;
+        char *index;
          u_short urll;


@@ -357,10 +357,10 @@
   * \param req    The http request struct of the top most http_request
   */

-static u_char NutSsiCheckForSsi(FILE *stream, char *buffer, u_short end, 
u_char* http_root, REQUEST *req)
+static u_char NutSsiCheckForSsi(FILE *stream, char *buffer, u_short end, 
char* http_root, REQUEST *req)
  {
      u_short pos = 4; // First character after comment start
-    u_char * filename;
+    char * filename;
      u_char type;

      pos = 4;
@@ -447,14 +447,14 @@
   */


-static void NutHttpProcessSHTML(FILE * stream, int fd, int file_len, 
u_char* http_root, REQUEST *req)
+static void NutHttpProcessSHTML(FILE * stream, int fd, int file_len, char* 
http_root, REQUEST *req)
  {
-    u_char * buffer;
+    char * buffer;
      u_char in_comment;
      int buffsize;
      int fpos;
      int n;
-    u_char *index;
+    char *index;
      u_char found;
      buffsize = MIN(BUFSIZE, file_len);
      buffer = NutHeapAlloc(buffsize+1);
diff -ruN nut/pro/wins.c nut-gcc4/pro/wins.c
--- nut/pro/wins.c	2005-11-24 10:46:55.000000000 +0100
+++ nut-gcc4/pro/wins.c	2006-03-07 19:20:26.000000000 +0100
@@ -89,7 +89,7 @@

  /* ********************************************************* */
  /* name : netbios label (15 chars max), ipaddr : network ordered IP 
address bytes */
-int NutWinsNameQuery(u_char * name, u_long ipaddr)
+int NutWinsNameQuery(char * name, u_long ipaddr)
  {
      WINSHEADER *pkt = NULL;
      u_char *encoded = NULL;
@@ -129,7 +129,7 @@
              (pkt->namelen != 0x20) ||   /* */
              (ntohs(pkt->type) != 32) || /* */
              (ntohs(pkt->class) != 1) || /* */
-            (strcmp(pkt->name, encoded)))
+            (strcmp((char *)pkt->name, (char *)encoded)))
              continue;           /* bad request, try again */
           /* printf("Name=%s recognized\r\n", name); */
          /* build RFC1002 Positive Name Query Response */




More information about the En-Nut-Discussion mailing list