move OSX compatible <endian.h> exception to a common "endian_compat.h" header

This commit is contained in:
Alejandro Mery 2012-08-07 00:18:34 +00:00
parent 329a13ed75
commit bcde0fc721
4 changed files with 18 additions and 11 deletions

10
fel.c
View File

@ -29,15 +29,7 @@
#include <stdio.h>
#include <errno.h>
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#define htole32(x) CFSwapInt32HostToLittle(x)
#define le32toh(x) CFSwapInt32LittleToHost(x)
#define htole16(x) CFSwapInt16HostToLittle(x)
#define le16toh(x) CFSwapInt16LittleToHost(x)
#else
#include <endian.h>
#endif
#include "endian_compat.h"
int errno;

14
include/endian_compat.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef SUNXI_ENDIAN_COMPAT_H_
#define SUNXI_ENDIAN_COMPAT_H_
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#define htole32(x) CFSwapInt32HostToLittle(x)
#define le32toh(x) CFSwapInt32LittleToHost(x)
#define htole16(x) CFSwapInt16HostToLittle(x)
#define le16toh(x) CFSwapInt16LittleToHost(x)
#else
#include <endian.h>
#endif
#endif

View File

@ -21,9 +21,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include <unistd.h>
#include "endian_compat.h"
struct phoenix_ptable {
char signature[16]; /* "PHOENIX_CARD_IMG" */
unsigned int unknown1; /* 0x00200100 */

2
pio.c
View File

@ -9,7 +9,7 @@
#include <stdlib.h>
#include <errno.h>
#include <endian.h>
#include "endian_compat.h"
#define PIO_REG_SIZE 0x228 /*0x300*/
#define PIO_PORT_SIZE 0x24