#include "config.h"

#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef RBX_WINDOWS
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include <sys/stat.h>
#include <errno.h>
#include <time.h>
#include <math.h>

#include "windows_compat.h"
#include "ffi_util.hpp"

#ifdef __APPLE__
#include <crt_externs.h>
#endif

extern "C" {

extern char** environ;

int ffi_errno() { return errno; }

char** ffi_environ() {
#ifdef __APPLE__
  return *_NSGetEnviron();
#else
  return environ;
#endif
}

void ffi_set_errno(int n) {
  errno = n;
}

#ifndef major
#define major(x) x
#endif

#ifndef minor
#define minor(x) 0
#endif

long ffi_major(dev_t n) {
  return major(n);
}

long ffi_minor(dev_t n) {
  return minor(n);
}

}

#include "config.h"

#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysmacros.h>
#ifdef RBX_WINDOWS
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include <sys/stat.h>
#include <errno.h>
#include <time.h>
#include <math.h>

#include "windows_compat.h"
#include "ffi_util.hpp"

#ifdef __APPLE__
#include <crt_externs.h>
#endif

extern "C" {

extern char** environ;

int ffi_errno() { return errno; }

char** ffi_environ() {
#ifdef __APPLE__
  return *_NSGetEnviron();
#else
  return environ;
#endif
}

void ffi_set_errno(int n) {
  errno = n;
}

#ifndef major
#define major(x) x
#endif

#ifndef minor
#define minor(x) 0
#endif

long ffi_major(dev_t n) {
  return major(n);
}

long ffi_minor(dev_t n) {
  return minor(n);
}

}

Fix warning on Ubuntu Bionic.
Fix warning on Ubuntu Bionic.

      machine/ffi_util.cpp:53:10: warning: In the GNU C Library, "major" is defined by <sys/sysmacros.h>.
      For historical compatibility, it is currently defined by <sys/types.h> as well, but we plan to
      remove this soon. To use "major", include <sys/sysmacros.h> directly. If you did not intend to
      use a system-defined macro "major", you should undefine it after including <sys/types.h>.
      [-W#pragma-messages]
