Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on macOS: error: unknown type name 'ssize_t'; error: 'SOL_SOCKET' undeclared (first use in this function); etc. #20

Open
barracuda156 opened this issue Jan 30, 2023 · 25 comments

Comments

@barracuda156
Copy link
Contributor

In file included from src/libsam3a/libsam3a.c:12:
src/libsam3a/libsam3a.h:55:46: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   55 | extern uint64_t sam3atimeval2ms(const struct timeval *tv);
      |                                              ^~~~~~~
src/libsam3a/libsam3a.h:56:36: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   56 | extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
      |                                    ^~~~~~~
In file included from src/libsam3/libsam3.c:10:
src/libsam3/libsam3.h:66:8: error: unknown type name 'ssize_t'
   66 | extern ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize,
      |        ^~~~~~~
src/libsam3/libsam3.h:69:8: error: unknown type name 'ssize_t'
   69 | extern ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize);
      |        ^~~~~~~
src/libsam3/libsam3.h:293:8: error: unknown type name 'ssize_t'
  293 | extern ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize);
      |        ^~~~~~~
src/libsam3/libsam3.h:309:8: error: unknown type name 'ssize_t'
  309 | extern ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |        ^~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpSetTimeoutSend':
src/libsam3/libsam3.c:65:13: warning: implicit declaration of function 'setsockopt' [-Wimplicit-function-declaration]
   65 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |             ^~~~~~~~~~
src/libsam3a/libsam3a.c:53:10: error: conflicting types for 'sam3atimeval2ms'; have 'uint64_t(const struct timeval *)' {aka 'long long unsigned int(const struct timeval *)'}
   53 | uint64_t sam3atimeval2ms(const struct timeval *tv) {
      |          ^~~~~~~~~~~~~~~
src/libsam3a/libsam3a.h:55:17: note: previous declaration of 'sam3atimeval2ms' with type 'uint64_t(const struct timeval *)' {aka 'long long unsigned int(const struct timeval *)'}
   55 | extern uint64_t sam3atimeval2ms(const struct timeval *tv);
      |                 ^~~~~~~~~~~~~~~
src/libsam3/libsam3.c:65:28: error: 'SOL_SOCKET' undeclared (first use in this function)
   65 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                            ^~~~~~~~~~
src/libsam3a/libsam3a.c:57:6: error: conflicting types for 'sam3ams2timeval'; have 'void(struct timeval *, uint64_t)' {aka 'void(struct timeval *, long long unsigned int)'}
   57 | void sam3ams2timeval(struct timeval *tv, uint64_t ms) {
      |      ^~~~~~~~~~~~~~~
src/libsam3/libsam3.c:65:28: note: each undeclared identifier is reported only once for each function it appears in
src/libsam3a/libsam3a.h:56:13: note: previous declaration of 'sam3ams2timeval' with type 'void(struct timeval *, uint64_t)' {aka 'void(struct timeval *, long long unsigned int)'}
   56 | extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
      |             ^~~~~~~~~~~~~~~
src/libsam3/libsam3.c:65:40: error: 'SO_SNDTIMEO' undeclared (first use in this function)
   65 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                                        ^~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpSetTimeoutReceive':
src/libsam3/libsam3.c:76:28: error: 'SOL_SOCKET' undeclared (first use in this function)
   76 |     return (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                            ^~~~~~~~~~
src/libsam3/libsam3.c:76:40: error: 'SO_RCVTIMEO' undeclared (first use in this function)
   76 |     return (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                                        ^~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnectIP':
src/libsam3/libsam3.c:91:22: error: storage size of 'addr' isn't known
   91 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c: In function 'sam3aBytesAvail':
src/libsam3a/libsam3a.c:117:7: warning: implicit declaration of function 'ioctl' [-Wimplicit-function-declaration]
  117 |   if (ioctl(fd, FIONREAD, &av) < 0)
      |       ^~~~~
src/libsam3/libsam3.c:98:13: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
   98 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |             ^~~~~~
src/libsam3a/libsam3a.c:117:17: error: 'FIONREAD' undeclared (first use in this function)
  117 |   if (ioctl(fd, FIONREAD, &av) < 0)
      |                 ^~~~~~~~
src/libsam3a/libsam3a.c:117:17: note: each undeclared identifier is reported only once for each function it appears in
src/libsam3/libsam3.c:98:20: error: 'AF_INET' undeclared (first use in this function)
   98 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |                    ^~~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aResolveHost':
src/libsam3a/libsam3a.c:127:15: warning: implicit declaration of function 'gethostbyname'; did you mean 'gethostname'? [-Wimplicit-function-declaration]
  127 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |               ^~~~~~~~~~~~~
      |               gethostname
src/libsam3/libsam3.c:98:29: error: 'SOCK_STREAM' undeclared (first use in this function)
   98 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |                             ^~~~~~~~~~~
src/libsam3a/libsam3a.c:127:13: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  127 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |             ^
src/libsam3a/libsam3a.c:127:55: error: invalid use of undefined type 'struct hostent'
  127 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |                                                       ^~
src/libsam3a/libsam3a.c:128:12: error: invalid use of undefined type 'struct hostent'
  128 |       !host->h_addr_list[0][0]) {
      |            ^~
src/libsam3a/libsam3a.c:133:33: error: invalid use of undefined type 'struct hostent'
  133 |   return ((struct in_addr *)host->h_addr_list[0])->s_addr;
      |                                 ^~
src/libsam3/libsam3.c:111:9: warning: implicit declaration of function 'getnameinfo' [-Wimplicit-function-declaration]
  111 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |         ^~~~~~~~~~~
src/libsam3/libsam3.c:111:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  111 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |                                                      ^~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aConnect':
src/libsam3a/libsam3a.c:145:13: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
  145 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |             ^~~~~~
src/libsam3/libsam3.c:112:45: error: 'NI_NUMERICHOST' undeclared (first use in this function)
  112 |                     sizeof(ipstr), NULL, 0, NI_NUMERICHOST) == 0) {
      |                                             ^~~~~~~~~~~~~~
src/libsam3a/libsam3a.c:145:20: error: 'AF_INET' undeclared (first use in this function)
  145 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                    ^~~~~~~
src/libsam3/libsam3.c:117:18: error: 'SOL_SOCKET' undeclared (first use in this function)
  117 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                  ^~~~~~~~~~
src/libsam3a/libsam3a.c:145:29: error: 'SOCK_STREAM' undeclared (first use in this function)
  145 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                             ^~~~~~~~~~~
src/libsam3/libsam3.c:117:30: error: 'SO_KEEPALIVE' undeclared (first use in this function)
  117 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                              ^~~~~~~~~~~~
src/libsam3a/libsam3a.c:145:43: error: 'SOCK_NONBLOCK' undeclared (first use in this function); did you mean 'SIG_UNBLOCK'?
  145 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                                           ^~~~~~~~~~~~~
      |                                           SIG_UNBLOCK
src/libsam3/libsam3.c:119:7: warning: implicit declaration of function 'connect' [-Wimplicit-function-declaration]
  119 |   if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |       ^~~~~~~
src/libsam3/libsam3.c:119:52: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  119 |   if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |                                                    ^~~~~~
src/libsam3a/libsam3a.c:145:59: error: 'SOCK_CLOEXEC' undeclared (first use in this function)
  145 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                                                           ^~~~~~~~~~~~
src/libsam3/libsam3.c:91:22: warning: unused variable 'addr' [-Wunused-variable]
   91 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c:148:3: warning: implicit declaration of function 'setsockopt' [-Wimplicit-function-declaration]
  148 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |   ^~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnect':
src/libsam3/libsam3.c:139:10: warning: implicit declaration of function 'gethostbyname'; did you mean 'gethostname'? [-Wimplicit-function-declaration]
  139 |   host = gethostbyname(hostname);
      |          ^~~~~~~~~~~~~
      |          gethostname
src/libsam3a/libsam3a.c:148:18: error: 'SOL_SOCKET' undeclared (first use in this function)
  148 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                  ^~~~~~~~~~
src/libsam3/libsam3.c:139:8: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  139 |   host = gethostbyname(hostname);
      |        ^
src/libsam3/libsam3.c:140:27: error: invalid use of undefined type 'struct hostent'
  140 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                           ^~
src/libsam3/libsam3.c:140:52: error: invalid use of undefined type 'struct hostent'
  140 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                                                    ^~
src/libsam3/libsam3.c:149:24: error: storage size of 'addr' isn't known
  149 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3a/libsam3a.c:148:30: error: 'SO_KEEPALIVE' undeclared (first use in this function)
  148 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                              ^~~~~~~~~~~~
src/libsam3a/libsam3a.c:151:24: error: storage size of 'addr' isn't known
  151 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3a/libsam3a.c:158:9: warning: implicit declaration of function 'connect' [-Wimplicit-function-declaration]
  158 |     if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |         ^~~~~~~
src/libsam3/libsam3.c:151:23: error: 'AF_INET' undeclared (first use in this function)
  151 |     addr.sin_family = AF_INET;
      |                       ^~~~~~~
src/libsam3a/libsam3a.c:158:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  158 |     if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |                                                      ^~~~~~
src/libsam3/libsam3.c:153:45: error: invalid use of undefined type 'struct hostent'
  153 |     addr.sin_addr = *((struct in_addr *)host->h_addr);
      |                                             ^~
src/libsam3/libsam3.c:155:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  155 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |                                                      ^~~~~~
src/libsam3a/libsam3a.c:151:24: warning: unused variable 'addr' [-Wunused-variable]
  151 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3a/libsam3a.c: In function 'sam3aDisconnect':
src/libsam3a/libsam3a.c:179:5: warning: implicit declaration of function 'shutdown' [-Wimplicit-function-declaration]
  179 |     shutdown(fd, SHUT_RDWR);
      |     ^~~~~~~~
src/libsam3/libsam3.c:156:45: error: 'NI_NUMERICHOST' undeclared (first use in this function)
  156 |                     sizeof(ipstr), NULL, 0, NI_NUMERICHOST) == 0) {
      |                                             ^~~~~~~~~~~~~~
src/libsam3/libsam3.c:149:24: warning: unused variable 'addr' [-Wunused-variable]
  149 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3/libsam3.c:162:34: error: invalid use of undefined type 'struct hostent'
  162 |     *ip = ((struct in_addr *)host->h_addr)->s_addr;
      |                                  ^~
src/libsam3/libsam3.c:163:50: error: invalid use of undefined type 'struct hostent'
  163 |   return sam3tcpConnectIP(((struct in_addr *)host->h_addr)->s_addr, port);
      |                                                  ^~
src/libsam3a/libsam3a.c:179:18: error: 'SHUT_RDWR' undeclared (first use in this function)
  179 |     shutdown(fd, SHUT_RDWR);
      |                  ^~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpDisconnect':
src/libsam3/libsam3.c:169:5: warning: implicit declaration of function 'shutdown' [-Wimplicit-function-declaration]
  169 |     shutdown(fd, SHUT_RDWR);
      |     ^~~~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aSendBytes':
src/libsam3a/libsam3a.c:196:14: warning: implicit declaration of function 'send' [-Wimplicit-function-declaration]
  196 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |              ^~~~
src/libsam3/libsam3.c:169:18: error: 'SHUT_RDWR' undeclared (first use in this function)
  169 |     shutdown(fd, SHUT_RDWR);
      |                  ^~~~~~~~~
src/libsam3a/libsam3a.c:196:35: error: 'MSG_NOSIGNAL' undeclared (first use in this function)
  196 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |                                   ^~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpSend':
src/libsam3/libsam3.c:185:14: warning: implicit declaration of function 'send' [-Wimplicit-function-declaration]
  185 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |              ^~~~
src/libsam3/libsam3.c:185:35: error: 'MSG_NOSIGNAL' undeclared (first use in this function)
  185 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |                                   ^~~~~~~~~~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:201:9: error: conflicting types for 'sam3tcpReceiveEx'; have 'ssize_t(int,  void *, size_t,  int)' {aka 'long int(int,  void *, long unsigned int,  int)'}
  201 | ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize, int allowPartial) {
      |         ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:66:16: note: previous declaration of 'sam3tcpReceiveEx' with type 'int(int,  void *, size_t,  int)' {aka 'int(int,  void *, long unsigned int,  int)'}
   66 | extern ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize,
      |                ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpReceiveEx':
src/libsam3/libsam3.c:209:14: warning: implicit declaration of function 'recv' [-Wimplicit-function-declaration]
  209 |     int rd = recv(fd, c, bufSize, 0);
      |              ^~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:227:9: error: conflicting types for 'sam3tcpReceive'; have 'ssize_t(int,  void *, size_t)' {aka 'long int(int,  void *, long unsigned int)'}
  227 | ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize) {
      |         ^~~~~~~~~~~~~~
src/libsam3/libsam3.h:69:16: note: previous declaration of 'sam3tcpReceive' with type 'int(int,  void *, size_t)' {aka 'int(int,  void *, long unsigned int)'}
   69 | extern ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize);
      |                ^~~~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpReceiveStr':
src/libsam3/libsam3.c:281:39: error: 'MSG_PEEK' undeclared (first use in this function)
  281 |     int rd = recv(fd, d, maxSize - 1, MSG_PEEK);
      |                                       ^~~~~~~~
src/libsam3/libsam3.c: In function 'sam3udpSendToIP':
src/libsam3/libsam3.c:320:22: error: storage size of 'addr' isn't known
  320 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3/libsam3.c:328:20: error: 'AF_INET' undeclared (first use in this function)
  328 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                    ^~~~~~~
src/libsam3/libsam3.c:328:29: error: 'SOCK_DGRAM' undeclared (first use in this function)
  328 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                             ^~~~~~~~~~
src/libsam3/libsam3.c:328:41: error: 'IPPROTO_UDP' undeclared (first use in this function)
  328 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                                         ^~~~~~~~~~~
src/libsam3/libsam3.c:339:9: warning: implicit declaration of function 'sendto' [-Wimplicit-function-declaration]
  339 |   res = sendto(fd, buf, bufSize, 0, (struct sockaddr *)&addr, sizeof(addr));
      |         ^~~~~~
src/libsam3a/libsam3a.c: In function 'genSeed':
src/libsam3a/libsam3a.c:654:18: error: storage size of 'sy' isn't known
  654 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c:320:22: warning: unused variable 'addr' [-Wunused-variable]
  320 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c:657:3: warning: implicit declaration of function 'sysinfo' [-Wimplicit-function-declaration]
  657 |   sysinfo(&sy);
      |   ^~~~~~~
src/libsam3/libsam3.c: In function 'sam3udpSendTo':
src/libsam3/libsam3.c:368:8: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  368 |   host = gethostbyname(hostname);
      |        ^
src/libsam3/libsam3.c:369:27: error: invalid use of undefined type 'struct hostent'
  369 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                           ^~
src/libsam3/libsam3.c:369:52: error: invalid use of undefined type 'struct hostent'
  369 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                                                    ^~
src/libsam3a/libsam3a.c:654:18: warning: unused variable 'sy' [-Wunused-variable]
  654 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c:376:34: error: invalid use of undefined type 'struct hostent'
  376 |     *ip = ((struct in_addr *)host->h_addr)->s_addr;
      |                                  ^~
src/libsam3/libsam3.c:377:49: error: invalid use of undefined type 'struct hostent'
  377 |   return sam3udpSendToIP(((struct in_addr *)host->h_addr)->s_addr, port, buf,
      |                                                 ^~
src/libsam3a/libsam3a.c: In function 'connDisconnect':
src/libsam3a/libsam3a.c:733:24: error: 'SHUT_RDWR' undeclared (first use in this function)
  733 |     shutdown(conn->fd, SHUT_RDWR);
      |                        ^~~~~~~~~
src/libsam3a/libsam3a.c: In function 'sesDisconnect':
src/libsam3a/libsam3a.c:747:23: error: 'SHUT_RDWR' undeclared (first use in this function)
  747 |     shutdown(ses->fd, SHUT_RDWR);
      |                       ^~~~~~~~~
src/libsam3a/libsam3a.c: In function 'aioLineReader':
src/libsam3a/libsam3a.c:799:15: warning: implicit declaration of function 'recv' [-Wimplicit-function-declaration]
  799 |     if ((rd = recv(fd, aio->data + aio->dataPos, rd, MSG_PEEK)) < 0) {
      |               ^~~~
src/libsam3/libsam3.c: In function 'genSeed':
src/libsam3a/libsam3a.c:799:54: error: 'MSG_PEEK' undeclared (first use in this function)
  799 |     if ((rd = recv(fd, aio->data + aio->dataPos, rd, MSG_PEEK)) < 0) {
      |                                                      ^~~~~~~~
src/libsam3/libsam3.c:614:18: error: storage size of 'sy' isn't known
  614 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c:617:3: warning: implicit declaration of function 'sysinfo' [-Wimplicit-function-declaration]
  617 |   sysinfo(&sy);
      |   ^~~~~~~
src/libsam3/libsam3.c:614:18: warning: unused variable 'sy' [-Wunused-variable]
  614 |   struct sysinfo sy;
      |                  ^~
src/libsam3a/libsam3a.c: In function 'aioSesConnected':
src/libsam3a/libsam3a.c:1002:3: error: unknown type name 'socklen_t'
 1002 |   socklen_t len = sizeof(res);
      |   ^~~~~~~~~
src/libsam3a/libsam3a.c:1004:7: warning: implicit declaration of function 'getsockopt'; did you mean 'getsubopt'? [-Wimplicit-function-declaration]
 1004 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |       ^~~~~~~~~~
      |       getsubopt
src/libsam3a/libsam3a.c:1004:27: error: 'SOL_SOCKET' undeclared (first use in this function)
 1004 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                           ^~~~~~~~~~
src/libsam3a/libsam3a.c:1004:39: error: 'SO_ERROR' undeclared (first use in this function)
 1004 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                                       ^~~~~~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:1160:9: error: conflicting types for 'sam3DatagramReceive'; have 'ssize_t(Sam3Session *, void *, size_t)' {aka 'long int(Sam3Session *, void *, long unsigned int)'}
 1160 | ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize) {
      |         ^~~~~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:293:16: note: previous declaration of 'sam3DatagramReceive' with type 'int(Sam3Session *, void *, size_t)' {aka 'int(Sam3Session *, void *, long unsigned int)'}
  293 | extern ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize);
      |                ^~~~~~~~~~~~~~~~~~~
src/libsam3/libsam3.c:1227:9: error: conflicting types for 'sam3Base32Encode'; have 'ssize_t(char *, size_t,  const void *, size_t)' {aka 'long int(char *, long unsigned int,  const void *, long unsigned int)'}
 1227 | ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |         ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:309:16: note: previous declaration of 'sam3Base32Encode' with type 'int(char *, size_t,  const void *, size_t)' {aka 'int(char *, long unsigned int,  const void *, long unsigned int)'}
  309 | extern ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |                ^~~~~~~~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'aioConnConnected':
src/libsam3a/libsam3a.c:1458:3: error: unknown type name 'socklen_t'
 1458 |   socklen_t len = sizeof(res);
      |   ^~~~~~~~~
src/libsam3a/libsam3a.c:1460:28: error: 'SOL_SOCKET' undeclared (first use in this function)
 1460 |   if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                            ^~~~~~~~~~
src/libsam3a/libsam3a.c:1460:40: error: 'SO_ERROR' undeclared (first use in this function)
 1460 |   if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                                        ^~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnect':
src/libsam3/libsam3.c:164:1: warning: control reaches end of non-void function [-Wreturn-type]
  164 | }
      | ^
src/libsam3/libsam3.c: In function 'sam3udpSendTo':
src/libsam3/libsam3.c:379:1: warning: control reaches end of non-void function [-Wreturn-type]
  379 | }
      | ^
src/libsam3a/libsam3a.c: In function 'sam3aResolveHost':
src/libsam3a/libsam3a.c:134:1: warning: control reaches end of non-void function [-Wreturn-type]
  134 | }
      | ^
make: *** [src/libsam3/libsam3.o] Error 1
@barracuda156
Copy link
Contributor Author

Some of these are fixable:

  1. libsam3.h needs this:
#include <sys/types.h>

This fixes undefined ssize_t.

  1. libsam3.c is missing #include <sys/ioctl.h>. See: https://codeberg.org/a-j-wood/pv/issues/74

  2. Also in both libsam3.c and libsam3a.c instead of #ifdef __unix__ it should be:

#if defined(__unix__) || defined(__APPLE__)

(I am not sure if __unix__ is defined on Linux; likely these headers are needed on Linux too.)

  1. However, <sys/sysinfo.h> is Linux-only header, it should not be used on macOS. I do not have a fix for this.

@eyedeekay @obscuratus Can this be addressed?

@eyedeekay
Copy link
Contributor

Sorry about the delay, I will figure this out when I get back to my office where my Mac is.

@barracuda156
Copy link
Contributor Author

@eyedeekay Greatly appreciated, thank you.

@obscuratus
Copy link

Not really sure why I was mentioned here :)

@barracuda156
Copy link
Contributor Author

@obscuratus Sorry, feel free to ignore. I just looked who have committed to the source, and tagged to get some attention to the issue, which was open for some months.

@defnax
Copy link

defnax commented Nov 21, 2023

any news foe a fix?

@eyedeekay
Copy link
Contributor

any news foe a fix?

I'll get it as soon as I can in the next few days, I'm not normally a Mac user so I'm a shade unfamiliar with the tooling.

@defnax
Copy link

defnax commented Dec 1, 2023

no fix yet?

@defnax
Copy link

defnax commented Dec 6, 2023

Hi, when comes the fix to master?

@eyedeekay
Copy link
Contributor

As soon as I can get to it, probably sometime around the 19th, I'm pretty swamped with the upcoming release right now and need a little more time.

@barracuda156
Copy link
Contributor Author

As soon as I can get to it, probably sometime around the 19th, I'm pretty swamped with the upcoming release right now and need a little more time.

Sounds good!

I just back to my PowerPC hardware, and right into the disaster of broken OpenBLAS build and a need to update/fix quite a number of related ports. So will also be busy for coming 3–4 days.
In a positive side, I can now test on all archs from ppc to aarch64.

@barracuda156
Copy link
Contributor Author

No surprise here, but just for the record: here is the failure on 10.6 with gcc13:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_security_libsam3/libsam3/work/compwrap/cc/opt/local/bin/gcc-mp-13 -Wall -g -O2 -std=gnu99 -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -c src/libsam3a/libsam3a.c -o src/libsam3a/libsam3a.o
In file included from src/libsam3a/libsam3a.c:26:
src/libsam3a/libsam3a.h:69:46: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   69 | extern uint64_t sam3atimeval2ms(const struct timeval *tv);
      |                                              ^~~~~~~
src/libsam3a/libsam3a.h:70:36: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
   70 | extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
      |                                    ^~~~~~~
In file included from src/libsam3/libsam3.c:26:
src/libsam3/libsam3.h:81:8: error: unknown type name 'ssize_t'
   81 | extern ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize,
      |        ^~~~~~~
src/libsam3/libsam3.h:84:8: error: unknown type name 'ssize_t'
   84 | extern ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize);
      |        ^~~~~~~
src/libsam3/libsam3.h:308:8: error: unknown type name 'ssize_t'
  308 | extern ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize);
      |        ^~~~~~~
src/libsam3/libsam3.h:324:8: error: unknown type name 'ssize_t'
  324 | extern ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |        ^~~~~~~
src/libsam3a/libsam3a.c:67:10: error: conflicting types for 'sam3atimeval2ms'; have 'uint64_t(const struct timeval *)' {aka 'long long unsigned int(const struct timeval *)'}
   67 | uint64_t sam3atimeval2ms(const struct timeval *tv) {
      |          ^~~~~~~~~~~~~~~
src/libsam3a/libsam3a.h:69:17: note: previous declaration of 'sam3atimeval2ms' with type 'uint64_t(const struct timeval *)' {aka 'long long unsigned int(const struct timeval *)'}
   69 | extern uint64_t sam3atimeval2ms(const struct timeval *tv);
      |                 ^~~~~~~~~~~~~~~
src/libsam3a/libsam3a.c:71:6: error: conflicting types for 'sam3ams2timeval'; have 'void(struct timeval *, uint64_t)' {aka 'void(struct timeval *, long long unsigned int)'}
   71 | void sam3ams2timeval(struct timeval *tv, uint64_t ms) {
      |      ^~~~~~~~~~~~~~~
src/libsam3a/libsam3a.h:70:13: note: previous declaration of 'sam3ams2timeval' with type 'void(struct timeval *, uint64_t)' {aka 'void(struct timeval *, long long unsigned int)'}
   70 | extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
      |             ^~~~~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpSetTimeoutSend':
src/libsam3/libsam3.c:81:13: warning: implicit declaration of function 'setsockopt' [-Wimplicit-function-declaration]
   81 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |             ^~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aBytesAvail':
src/libsam3a/libsam3a.c:131:7: warning: implicit declaration of function 'ioctl' [-Wimplicit-function-declaration]
  131 |   if (ioctl(fd, FIONREAD, &av) < 0)
      |       ^~~~~
src/libsam3/libsam3.c:81:28: error: 'SOL_SOCKET' undeclared (first use in this function)
   81 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                            ^~~~~~~~~~
src/libsam3/libsam3.c:81:28: note: each undeclared identifier is reported only once for each function it appears in
src/libsam3a/libsam3a.c:131:17: error: 'FIONREAD' undeclared (first use in this function)
  131 |   if (ioctl(fd, FIONREAD, &av) < 0)
      |                 ^~~~~~~~
src/libsam3a/libsam3a.c:131:17: note: each undeclared identifier is reported only once for each function it appears in
src/libsam3a/libsam3a.c: In function 'sam3aResolveHost':
src/libsam3a/libsam3a.c:141:15: warning: implicit declaration of function 'gethostbyname'; did you mean 'gethostname'? [-Wimplicit-function-declaration]
  141 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |               ^~~~~~~~~~~~~
      |               gethostname
src/libsam3a/libsam3a.c:141:13: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  141 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |             ^
src/libsam3a/libsam3a.c:141:55: error: invalid use of undefined type 'struct hostent'
  141 |   if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
      |                                                       ^~
src/libsam3a/libsam3a.c:142:12: error: invalid use of undefined type 'struct hostent'
  142 |       !host->h_addr_list[0][0]) {
      |            ^~
src/libsam3a/libsam3a.c:147:33: error: invalid use of undefined type 'struct hostent'
  147 |   return ((struct in_addr *)host->h_addr_list[0])->s_addr;
      |                                 ^~
src/libsam3a/libsam3a.c: In function 'sam3aConnect':
src/libsam3a/libsam3a.c:159:13: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
  159 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |             ^~~~~~
src/libsam3/libsam3.c:81:40: error: 'SO_SNDTIMEO' undeclared (first use in this function)
   81 |     return (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                                        ^~~~~~~~~~~
src/libsam3a/libsam3a.c:159:20: error: 'AF_INET' undeclared (first use in this function)
  159 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                    ^~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpSetTimeoutReceive':
src/libsam3/libsam3.c:92:28: error: 'SOL_SOCKET' undeclared (first use in this function)
   92 |     return (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                            ^~~~~~~~~~
src/libsam3a/libsam3a.c:159:29: error: 'SOCK_STREAM' undeclared (first use in this function)
  159 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                             ^~~~~~~~~~~
src/libsam3/libsam3.c:92:40: error: 'SO_RCVTIMEO' undeclared (first use in this function)
   92 |     return (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0 ? -1
      |                                        ^~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnectIP':
src/libsam3/libsam3.c:107:22: error: storage size of 'addr' isn't known
  107 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c:159:43: error: 'SOCK_NONBLOCK' undeclared (first use in this function); did you mean 'SIG_UNBLOCK'?
  159 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                                           ^~~~~~~~~~~~~
      |                                           SIG_UNBLOCK
src/libsam3/libsam3.c:114:13: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
  114 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |             ^~~~~~
src/libsam3a/libsam3a.c:159:59: error: 'SOCK_CLOEXEC' undeclared (first use in this function)
  159 |   if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
      |                                                           ^~~~~~~~~~~~
src/libsam3/libsam3.c:114:20: error: 'AF_INET' undeclared (first use in this function)
  114 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |                    ^~~~~~~
src/libsam3a/libsam3a.c:162:3: warning: implicit declaration of function 'setsockopt' [-Wimplicit-function-declaration]
  162 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |   ^~~~~~~~~~
src/libsam3/libsam3.c:114:29: error: 'SOCK_STREAM' undeclared (first use in this function)
  114 |   if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
      |                             ^~~~~~~~~~~
src/libsam3a/libsam3a.c:162:18: error: 'SOL_SOCKET' undeclared (first use in this function)
  162 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                  ^~~~~~~~~~
src/libsam3/libsam3.c:127:9: warning: implicit declaration of function 'getnameinfo' [-Wimplicit-function-declaration]
  127 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |         ^~~~~~~~~~~
src/libsam3/libsam3.c:127:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  127 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |                                                      ^~~~~~
src/libsam3a/libsam3a.c:162:30: error: 'SO_KEEPALIVE' undeclared (first use in this function)
  162 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                              ^~~~~~~~~~~~
src/libsam3a/libsam3a.c:165:24: error: storage size of 'addr' isn't known
  165 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3a/libsam3a.c:172:9: warning: implicit declaration of function 'connect' [-Wimplicit-function-declaration]
  172 |     if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |         ^~~~~~~
src/libsam3a/libsam3a.c:172:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  172 |     if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |                                                      ^~~~~~
src/libsam3a/libsam3a.c:165:24: warning: unused variable 'addr' [-Wunused-variable]
  165 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3/libsam3.c:128:45: error: 'NI_NUMERICHOST' undeclared (first use in this function)
  128 |                     sizeof(ipstr), NULL, 0, NI_NUMERICHOST) == 0) {
      |                                             ^~~~~~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aDisconnect':
src/libsam3a/libsam3a.c:193:5: warning: implicit declaration of function 'shutdown' [-Wimplicit-function-declaration]
  193 |     shutdown(fd, SHUT_RDWR);
      |     ^~~~~~~~
src/libsam3/libsam3.c:133:18: error: 'SOL_SOCKET' undeclared (first use in this function)
  133 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                  ^~~~~~~~~~
src/libsam3a/libsam3a.c:193:18: error: 'SHUT_RDWR' undeclared (first use in this function)
  193 |     shutdown(fd, SHUT_RDWR);
      |                  ^~~~~~~~~
src/libsam3/libsam3.c:133:30: error: 'SO_KEEPALIVE' undeclared (first use in this function)
  133 |   setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
      |                              ^~~~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'sam3aSendBytes':
src/libsam3a/libsam3a.c:210:14: warning: implicit declaration of function 'send' [-Wimplicit-function-declaration]
  210 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |              ^~~~
src/libsam3/libsam3.c:135:7: warning: implicit declaration of function 'connect' [-Wimplicit-function-declaration]
  135 |   if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |       ^~~~~~~
src/libsam3/libsam3.c:135:52: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  135 |   if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
      |                                                    ^~~~~~
src/libsam3/libsam3.c:107:22: warning: unused variable 'addr' [-Wunused-variable]
  107 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c:210:35: error: 'MSG_NOSIGNAL' undeclared (first use in this function)
  210 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |                                   ^~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnect':
src/libsam3/libsam3.c:155:10: warning: implicit declaration of function 'gethostbyname'; did you mean 'gethostname'? [-Wimplicit-function-declaration]
  155 |   host = gethostbyname(hostname);
      |          ^~~~~~~~~~~~~
      |          gethostname
src/libsam3/libsam3.c:155:8: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  155 |   host = gethostbyname(hostname);
      |        ^
src/libsam3/libsam3.c:156:27: error: invalid use of undefined type 'struct hostent'
  156 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                           ^~
src/libsam3/libsam3.c:156:52: error: invalid use of undefined type 'struct hostent'
  156 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                                                    ^~
src/libsam3/libsam3.c:165:24: error: storage size of 'addr' isn't known
  165 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3/libsam3.c:167:23: error: 'AF_INET' undeclared (first use in this function)
  167 |     addr.sin_family = AF_INET;
      |                       ^~~~~~~
src/libsam3/libsam3.c:169:45: error: invalid use of undefined type 'struct hostent'
  169 |     addr.sin_addr = *((struct in_addr *)host->h_addr);
      |                                             ^~
src/libsam3/libsam3.c:171:54: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in'
  171 |     if (getnameinfo((struct sockaddr *)&addr, sizeof(struct sockaddr_in), ipstr,
      |                                                      ^~~~~~
src/libsam3a/libsam3a.c: In function 'genSeed':
src/libsam3a/libsam3a.c:668:18: error: storage size of 'sy' isn't known
  668 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c:172:45: error: 'NI_NUMERICHOST' undeclared (first use in this function)
  172 |                     sizeof(ipstr), NULL, 0, NI_NUMERICHOST) == 0) {
      |                                             ^~~~~~~~~~~~~~
src/libsam3/libsam3.c:165:24: warning: unused variable 'addr' [-Wunused-variable]
  165 |     struct sockaddr_in addr;
      |                        ^~~~
src/libsam3/libsam3.c:178:34: error: invalid use of undefined type 'struct hostent'
  178 |     *ip = ((struct in_addr *)host->h_addr)->s_addr;
      |                                  ^~
src/libsam3/libsam3.c:179:50: error: invalid use of undefined type 'struct hostent'
  179 |   return sam3tcpConnectIP(((struct in_addr *)host->h_addr)->s_addr, port);
      |                                                  ^~
src/libsam3/libsam3.c: In function 'sam3tcpDisconnect':
src/libsam3/libsam3.c:185:5: warning: implicit declaration of function 'shutdown' [-Wimplicit-function-declaration]
  185 |     shutdown(fd, SHUT_RDWR);
      |     ^~~~~~~~
src/libsam3a/libsam3a.c:671:3: warning: implicit declaration of function 'sysinfo' [-Wimplicit-function-declaration]
  671 |   sysinfo(&sy);
      |   ^~~~~~~
src/libsam3/libsam3.c:185:18: error: 'SHUT_RDWR' undeclared (first use in this function)
  185 |     shutdown(fd, SHUT_RDWR);
      |                  ^~~~~~~~~
src/libsam3a/libsam3a.c:668:18: warning: unused variable 'sy' [-Wunused-variable]
  668 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c: In function 'sam3tcpSend':
src/libsam3/libsam3.c:201:14: warning: implicit declaration of function 'send' [-Wimplicit-function-declaration]
  201 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |              ^~~~
src/libsam3a/libsam3a.c: In function 'connDisconnect':
src/libsam3/libsam3.c:201:35: error: 'MSG_NOSIGNAL' undeclared (first use in this function)
  201 |     int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
      |                                   ^~~~~~~~~~~~
src/libsam3a/libsam3a.c:747:24: error: 'SHUT_RDWR' undeclared (first use in this function)
  747 |     shutdown(conn->fd, SHUT_RDWR);
      |                        ^~~~~~~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:217:9: error: conflicting types for 'sam3tcpReceiveEx'; have 'ssize_t(int,  void *, size_t,  int)' {aka 'long int(int,  void *, long unsigned int,  int)'}
  217 | ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize, int allowPartial) {
      |         ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:81:16: note: previous declaration of 'sam3tcpReceiveEx' with type 'int(int,  void *, size_t,  int)' {aka 'int(int,  void *, long unsigned int,  int)'}
   81 | extern ssize_t sam3tcpReceiveEx(int fd, void *buf, size_t bufSize,
      |                ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpReceiveEx':
src/libsam3/libsam3.c:225:14: warning: implicit declaration of function 'recv' [-Wimplicit-function-declaration]
  225 |     int rd = recv(fd, c, bufSize, 0);
      |              ^~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:243:9: error: conflicting types for 'sam3tcpReceive'; have 'ssize_t(int,  void *, size_t)' {aka 'long int(int,  void *, long unsigned int)'}
  243 | ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize) {
      |         ^~~~~~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'sesDisconnect':
src/libsam3/libsam3.h:84:16: note: previous declaration of 'sam3tcpReceive' with type 'int(int,  void *, size_t)' {aka 'int(int,  void *, long unsigned int)'}
   84 | extern ssize_t sam3tcpReceive(int fd, void *buf, size_t bufSize);
      |                ^~~~~~~~~~~~~~
src/libsam3a/libsam3a.c:761:23: error: 'SHUT_RDWR' undeclared (first use in this function)
  761 |     shutdown(ses->fd, SHUT_RDWR);
      |                       ^~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpReceiveStr':
src/libsam3/libsam3.c:297:39: error: 'MSG_PEEK' undeclared (first use in this function)
  297 |     int rd = recv(fd, d, maxSize - 1, MSG_PEEK);
      |                                       ^~~~~~~~
src/libsam3/libsam3.c: In function 'sam3udpSendToIP':
src/libsam3a/libsam3a.c: In function 'aioLineReader':
src/libsam3/libsam3.c:336:22: error: storage size of 'addr' isn't known
  336 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c:813:15: warning: implicit declaration of function 'recv' [-Wimplicit-function-declaration]
  813 |     if ((rd = recv(fd, aio->data + aio->dataPos, rd, MSG_PEEK)) < 0) {
      |               ^~~~
src/libsam3/libsam3.c:344:20: error: 'AF_INET' undeclared (first use in this function)
  344 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                    ^~~~~~~
src/libsam3a/libsam3a.c:813:54: error: 'MSG_PEEK' undeclared (first use in this function)
  813 |     if ((rd = recv(fd, aio->data + aio->dataPos, rd, MSG_PEEK)) < 0) {
      |                                                      ^~~~~~~~
src/libsam3/libsam3.c:344:29: error: 'SOCK_DGRAM' undeclared (first use in this function)
  344 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                             ^~~~~~~~~~
src/libsam3/libsam3.c:344:41: error: 'IPPROTO_UDP' undeclared (first use in this function)
  344 |   if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
      |                                         ^~~~~~~~~~~
src/libsam3/libsam3.c:355:9: warning: implicit declaration of function 'sendto' [-Wimplicit-function-declaration]
  355 |   res = sendto(fd, buf, bufSize, 0, (struct sockaddr *)&addr, sizeof(addr));
      |         ^~~~~~
src/libsam3/libsam3.c:336:22: warning: unused variable 'addr' [-Wunused-variable]
  336 |   struct sockaddr_in addr;
      |                      ^~~~
src/libsam3a/libsam3a.c: In function 'aioSesConnected':
src/libsam3/libsam3.c: In function 'sam3udpSendTo':
src/libsam3/libsam3.c:384:8: warning: assignment to 'struct hostent *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  384 |   host = gethostbyname(hostname);
      |        ^
src/libsam3/libsam3.c:385:27: error: invalid use of undefined type 'struct hostent'
  385 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                           ^~
src/libsam3/libsam3.c:385:52: error: invalid use of undefined type 'struct hostent'
  385 |   if (host == NULL || host->h_name == NULL || !host->h_name[0]) {
      |                                                    ^~
src/libsam3a/libsam3a.c:1016:3: error: unknown type name 'socklen_t'
 1016 |   socklen_t len = sizeof(res);
      |   ^~~~~~~~~
src/libsam3/libsam3.c:392:34: error: invalid use of undefined type 'struct hostent'
  392 |     *ip = ((struct in_addr *)host->h_addr)->s_addr;
      |                                  ^~
src/libsam3/libsam3.c:393:49: error: invalid use of undefined type 'struct hostent'
  393 |   return sam3udpSendToIP(((struct in_addr *)host->h_addr)->s_addr, port, buf,
      |                                                 ^~
src/libsam3a/libsam3a.c:1018:7: warning: implicit declaration of function 'getsockopt'; did you mean 'getsubopt'? [-Wimplicit-function-declaration]
 1018 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |       ^~~~~~~~~~
      |       getsubopt
src/libsam3/libsam3.c: In function 'genSeed':
src/libsam3/libsam3.c:630:18: error: storage size of 'sy' isn't known
  630 |   struct sysinfo sy;
      |                  ^~
src/libsam3/libsam3.c:633:3: warning: implicit declaration of function 'sysinfo' [-Wimplicit-function-declaration]
  633 |   sysinfo(&sy);
      |   ^~~~~~~
src/libsam3a/libsam3a.c:1018:27: error: 'SOL_SOCKET' undeclared (first use in this function)
 1018 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                           ^~~~~~~~~~
src/libsam3/libsam3.c:630:18: warning: unused variable 'sy' [-Wunused-variable]
  630 |   struct sysinfo sy;
      |                  ^~
src/libsam3a/libsam3a.c:1018:39: error: 'SO_ERROR' undeclared (first use in this function)
 1018 |   if (getsockopt(ses->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                                       ^~~~~~~~
src/libsam3/libsam3.c: At top level:
src/libsam3/libsam3.c:1177:9: error: conflicting types for 'sam3DatagramReceive'; have 'ssize_t(Sam3Session *, void *, size_t)' {aka 'long int(Sam3Session *, void *, long unsigned int)'}
 1177 | ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize) {
      |         ^~~~~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:308:16: note: previous declaration of 'sam3DatagramReceive' with type 'int(Sam3Session *, void *, size_t)' {aka 'int(Sam3Session *, void *, long unsigned int)'}
  308 | extern ssize_t sam3DatagramReceive(Sam3Session *ses, void *buf, size_t bufsize);
      |                ^~~~~~~~~~~~~~~~~~~
src/libsam3/libsam3.c:1244:9: error: conflicting types for 'sam3Base32Encode'; have 'ssize_t(char *, size_t,  const void *, size_t)' {aka 'long int(char *, long unsigned int,  const void *, long unsigned int)'}
 1244 | ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |         ^~~~~~~~~~~~~~~~
src/libsam3/libsam3.h:324:16: note: previous declaration of 'sam3Base32Encode' with type 'int(char *, size_t,  const void *, size_t)' {aka 'int(char *, long unsigned int,  const void *, long unsigned int)'}
  324 | extern ssize_t sam3Base32Encode(char *dest, size_t destsz, const void *srcbuf,
      |                ^~~~~~~~~~~~~~~~
src/libsam3a/libsam3a.c: In function 'aioConnConnected':
src/libsam3a/libsam3a.c:1472:3: error: unknown type name 'socklen_t'
 1472 |   socklen_t len = sizeof(res);
      |   ^~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3tcpConnect':
src/libsam3/libsam3.c:180:1: warning: control reaches end of non-void function [-Wreturn-type]
  180 | }
      | ^
src/libsam3a/libsam3a.c:1474:28: error: 'SOL_SOCKET' undeclared (first use in this function)
 1474 |   if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                            ^~~~~~~~~~
src/libsam3/libsam3.c: In function 'sam3udpSendTo':
src/libsam3/libsam3.c:395:1: warning: control reaches end of non-void function [-Wreturn-type]
  395 | }
      | ^
src/libsam3a/libsam3a.c:1474:40: error: 'SO_ERROR' undeclared (first use in this function)
 1474 |   if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &res, &len) == 0 && res == 0) {
      |                                        ^~~~~~~~
make: *** [src/libsam3/libsam3.o] Error 1
make: *** Waiting for unfinished jobs....
src/libsam3a/libsam3a.c: In function 'sam3aResolveHost':
src/libsam3a/libsam3a.c:148:1: warning: control reaches end of non-void function [-Wreturn-type]
  148 | }
      | ^
make: *** [src/libsam3a/libsam3a.o] Error 1

@eyedeekay
Copy link
Contributor

OK I'm almost through the release marathon and ready to get back to this tomorrow. Talk soon.

@barracuda156
Copy link
Contributor Author

@eyedeekay Awesome!

@eyedeekay
Copy link
Contributor

So I've applied the fixes you suggested and now the last thing to do before I merge macos-build-fixes is to decide what to do with sysinfo. IMO our use of it is kind of superfluous, we don't need it for the thing we're using it for so I'm just going to take that part and do something cross-platform there instead. Sorry about all the delays, been a rough week.

@barracuda156
Copy link
Contributor Author

@eyedeekay Sorry to disturb, but any luck with fixing this?

@eyedeekay
Copy link
Contributor

Yeah I just need to get back to my Mac workstation again to finish up.

@barracuda156
Copy link
Contributor Author

Great to hear, will be waiting for that.

@eyedeekay
Copy link
Contributor

@barracuda156 Sorry for the delay my Mac is broken, the PR here: #23 should resolve it but I will need you to help test it.

@barracuda156
Copy link
Contributor Author

@barracuda156 Sorry for the delay my Mac is broken, the PR here: #23 should resolve it but I will need you to help test it.

@eyedeekay Thank you! Will try that today and let you know.

@barracuda156
Copy link
Contributor Author

barracuda156 commented Feb 8, 2024

@eyedeekay Does not work yet: #23 (comment)

  1. libsam3.c includes <sys/sysinfo.h>, which does not exist on MacOS (same issue which is fixed for libsam3a.c in your PR).
  2. Perhaps, instead of defined(__unix__) || !defined(__APPLE__) it should be defined(__unix__) && !defined(__APPLE__)? It is unsafe IMO to use a negative form with OR here. Who knows whether some compiler defines __unix__ for some macOS? It is Unix-like OS after all.
  3. mach_absolute_time needs at least <mach/mach_time.h> to work.
  4. There are a few other errors which we need to look into.

@eyedeekay
Copy link
Contributor

Thanks much, not having a working Mac to test on has made this tricky, I'll try to iterate more quickly to help us catch them all.

@eyedeekay
Copy link
Contributor

Added your changes and finished up with some of my own which should finish, please take a look and test when you can thank you.

@barracuda156
Copy link
Contributor Author

Thank you for an update!

With new patches:

--->  Applying patches to libsam3
--->  Applying 0001-Fix-some-of-the-headers-to-make-progress-on-fixing-O.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0001-Fix-some-of-the-headers-to-make-progress-on-fixing-O.patch'
patching file 'src/libsam3/libsam3.c'
patching file 'src/libsam3/libsam3.h'
patching file 'src/libsam3a/libsam3a.c'
--->  Applying 0002-Use-PID-TickCount-for-random-nickname-string-on-__AP.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0002-Use-PID-TickCount-for-random-nickname-string-on-__AP.patch'
patching file 'src/libsam3a/libsam3a.c'
--->  Applying 0003-Disable-use-of-sysinfo.h-on-Mac-OSX-and-replace-depr.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0003-Disable-use-of-sysinfo.h-on-Mac-OSX-and-replace-depr.patch'
patching file 'src/libsam3a/libsam3a.c'
--->  Applying 0004-Update-src-libsam3-libsam3.c.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0004-Update-src-libsam3-libsam3.c.patch'
patching file 'src/libsam3/libsam3.c'
--->  Applying 0005-Update-src-libsam3a-libsam3a.c.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0005-Update-src-libsam3a-libsam3a.c.patch'
patching file 'src/libsam3a/libsam3a.c'
--->  Applying 0006-Use-getpid-and-TickCount-when-on-OSX-platforms.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0006-Use-getpid-and-TickCount-when-on-OSX-platforms.patch'
patching file 'src/libsam3/libsam3.c'
--->  Applying 0007-Include-mach_time-on-osx-platforms.patch
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/patch -p0 < '/opt/svacchanda/SonomaPorts/security/libsam3/files/0007-Include-mach_time-on-osx-platforms.patch'
patching file 'src/libsam3/libsam3.c'
patching file 'src/libsam3a/libsam3a.c'
--->  Configuring libsam3
--->  Building libsam3
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e" && /usr/bin/make -j4 -w build CC="/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/cc/usr/bin/clang" CXX="/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/cxx/usr/bin/clang++" OBJC="/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/objc/usr/bin/clang" OBJCXX="/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/objcxx/usr/bin/clang++" INSTALL="/usr/bin/install -c" 
make: Entering directory `/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/libsam3-2226ef0a20a001ec0942be6abe5e909c15447d8e'
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/cc/usr/bin/clang -Wall -g -O2 -std=gnu99 -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -arch arm64 -c src/libsam3/libsam3.c -o src/libsam3/libsam3.o
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_libsam3/libsam3/work/compwrap/cc/usr/bin/clang -Wall -g -O2 -std=gnu99 -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -arch arm64 -c src/libsam3a/libsam3a.c -o src/libsam3a/libsam3a.o
clangclang: warning: -Wl,-headerpad_max_install_names: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk: 'linker' input unused [-Wunused-command-line-argument]
: warning: -Wl,-headerpad_max_install_names: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk: 'linker' input unused [-Wunused-command-line-argument]
clangclang: : warning: warning: argument unused during compilation: '-L/opt/local/lib' [-Wunused-command-line-argument]argument unused during compilation: '-L/opt/local/lib' [-Wunused-command-line-argument]

In file included from src/libsam3a/libsam3a.c:26:
src/libsam3a/libsam3a.h:69:46: warning: declaration of 'struct timeval' will not be visible outside of this function [-Wvisibility]
extern uint64_t sam3atimeval2ms(const struct timeval *tv);
                                             ^
src/libsam3a/libsam3a.h:70:36: warning: declaration of 'struct timeval' will not be visible outside of this function [-Wvisibility]
extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
                                   ^
src/libsam3/libsam3.c:56:10: fatal error: 'sys/sysinfo.h' file not found
#include <sys/sysinfo.h>
         ^~~~~~~~~~~~~~~
1 error generated.
src/libsam3a/libsam3a.c:80:10: error: conflicting types for 'sam3atimeval2ms'
uint64_t sam3atimeval2ms(const struct timeval *tv) {
         ^
src/libsam3a/libsam3a.h:69:17: note: previous declaration is here
extern uint64_t sam3atimeval2ms(const struct timeval *tv);
                ^
src/libsam3a/libsam3a.c:84:6: error: conflicting types for 'sam3ams2timeval'
void sam3ams2timeval(struct timeval *tv, uint64_t ms) {
     ^
src/libsam3a/libsam3a.h:70:13: note: previous declaration is here
extern void sam3ams2timeval(struct timeval *tv, uint64_t ms);
            ^
src/libsam3a/libsam3a.c:144:7: error: call to undeclared function 'ioctl'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  if (ioctl(fd, FIONREAD, &av) < 0)
      ^
make: *** [src/libsam3/libsam3.o] Error 1
make: *** Waiting for unfinished jobs....
src/libsam3a/libsam3a.c:144:17: error: use of undeclared identifier 'FIONREAD'
  if (ioctl(fd, FIONREAD, &av) < 0)
                ^
src/libsam3a/libsam3a.c:154:15: error: call to undeclared function 'gethostbyname'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
              ^
src/libsam3a/libsam3a.c:154:15: note: did you mean 'gethostname'?
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/unistd.h:626:6: note: 'gethostname' declared here
int      gethostname(char *, size_t);
         ^
src/libsam3a/libsam3a.c:154:13: warning: incompatible integer to pointer conversion assigning to 'struct hostent *' from 'int' [-Wint-conversion]
  if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
            ^ ~~~~~~~~~~~~~~~~~~~~~~~
src/libsam3a/libsam3a.c:154:55: error: incomplete definition of type 'struct hostent'
  if ((host = gethostbyname(hostname)) == NULL || host->h_name == NULL ||
                                                  ~~~~^
src/libsam3a/libsam3a.c:150:10: note: forward declaration of 'struct hostent'
  struct hostent *host;
         ^
src/libsam3a/libsam3a.c:155:12: error: incomplete definition of type 'struct hostent'
      !host->h_addr_list[0][0]) {
       ~~~~^
src/libsam3a/libsam3a.c:150:10: note: forward declaration of 'struct hostent'
  struct hostent *host;
         ^
src/libsam3a/libsam3a.c:160:33: error: incomplete definition of type 'struct hostent'
  return ((struct in_addr *)host->h_addr_list[0])->s_addr;
                            ~~~~^
src/libsam3a/libsam3a.c:150:10: note: forward declaration of 'struct hostent'
  struct hostent *host;
         ^
src/libsam3a/libsam3a.c:160:50: error: incomplete definition of type 'struct in_addr'
  return ((struct in_addr *)host->h_addr_list[0])->s_addr;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
src/libsam3a/libsam3a.c:160:19: note: forward declaration of 'struct in_addr'
  return ((struct in_addr *)host->h_addr_list[0])->s_addr;
                  ^
src/libsam3a/libsam3a.c:172:13: error: call to undeclared function 'socket'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
            ^
src/libsam3a/libsam3a.c:172:20: error: use of undeclared identifier 'AF_INET'
  if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
                   ^
src/libsam3a/libsam3a.c:172:29: error: use of undeclared identifier 'SOCK_STREAM'
  if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
                            ^
src/libsam3a/libsam3a.c:172:43: error: use of undeclared identifier 'SOCK_NONBLOCK'
  if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
                                          ^
src/libsam3a/libsam3a.c:172:59: error: use of undeclared identifier 'SOCK_CLOEXEC'
  if ((fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
                                                          ^
src/libsam3a/libsam3a.c:175:3: error: call to undeclared function 'setsockopt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
  ^
src/libsam3a/libsam3a.c:175:18: error: use of undeclared identifier 'SOL_SOCKET'
  setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
                 ^
src/libsam3a/libsam3a.c:175:30: error: use of undeclared identifier 'SO_KEEPALIVE'
  setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
                             ^
src/libsam3a/libsam3a.c:178:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in addr;
                       ^
src/libsam3a/libsam3a.c:178:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in addr;
           ^
src/libsam3a/libsam3a.c:181:23: error: use of undeclared identifier 'AF_INET'
    addr.sin_family = AF_INET;
                      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
make: *** [src/libsam3a/libsam3a.o] Error 1

(sys/sysinfo.h was just missed in one spot, where it should have been removed.)

Re SOL_SOCKET: unbit/uwsgi#1056
I.e. apparently it is just not there on macOS.

Other stuff needs related headers, perhaps something like here: https://gist.github.com/lemonmojo/1b7f957aed60a65c121e8067d5d93483

@barracuda156
Copy link
Contributor Author

@eyedeekay By the way, maybe make a new release? Been quite a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants