ifneq ($(PSI_DEPS),)
clean: psi-clean-depend
endif
+
+.PHONY: psi-paranoid-backups
+psi-paranoid-backups:
+ -if test -z "$((DEST))"; then \
+ echo "Usage: make psi-paranoid-backups DEST=<repo to push to>"; \
+ else \
+ git ci -am flush; \
+ git push $DEST; \
+ fi
+
const char *name;
psi_func_ptr func;
} psi_func_redirs[] = {
+ /* inline byte swapping */
+#ifdef __APPLE__
+ {"_OSSwapInt16", psi_swap16},
+ {"_OSSwapInt32", psi_swap32},
+ {"_OSSwapInt64", psi_swap64}
+#elif defined(__FreeBSD__)
+ {"bswap16", psi_swap16}
+ {"bswap32", psi_swap32}
+ {"bswap64", psi_swap64}
+#elif defined(__OpenBSD__)
+ {"swap16", psi_swap16}
+ {"swap32", psi_swap32}
+ {"swap64", psi_swap64}
+#elif defined(__NetBSD__)
+ {"bswap16", psi_swap16}
+ {"bswap32", psi_swap32}
+ {"bswap64", psi_swap64}
+#endif
/* needed from libc_nonshared.a */
{"fstat", (psi_func_ptr) fstat},
{"fstatat", (psi_func_ptr) fstatat},
let dst = calloc(1, sizeof(struct sockaddr_storage));
return inet_pton(af, src, dst) as to_int(inet_pton);
set $dst = to_string(dst, sizeof(struct sockaddr_storage));
-}
\ No newline at end of file
+}
+#ifdef linux
lib "anl";
+#endif
#include <netdb.h>
return true;
}
+
+#ifdef __APPLE__
+#include <libkern/OSByteOrder.h>
+# define bswap_16(u) _OSSwapInt16(u)
+# define bswap_32(u) _OSSwapInt32(u)
+# define bswap_64(u) _OSSwapInt64(u)
+#elif defined(__FreeBSD__)
+# include <sys/endian.h>
+# define bswap_16(u) bswap16(u)
+# define bswap_32(u) bswap32(u)
+# define bswap_64(u) bswap64(u)
+#elif defined(__OpenBSD__)
+# include <sys/types.h>
+# define bswap_16(u) swap16(u)
+# define bswap_32(u) swap32(u)
+# define bswap_64(u) swap64(u)
+#elif defined(__NetBSD__)
+# include <sys/types.h>
+# include <machine/bswap.h>
+# define bswap_16(u) bswap16(u)
+# define bswap_32(u) bswap32(u)
+# define bswap_64(u) bswap64(u)
+#else
+# include <byteswap.h>
+#endif
+
+uint16_t psi_swap16(uint16_t u)
+{
+ return bswap_16(u);
+}
+
+uint32_t psi_swap32(uint32_t u)
+{
+ return bswap_32(u);
+}
+
+uint64_t psi_swap64(uint64_t u)
+{
+ return bswap_64(u);
+}
bool psi_builtin_exists(zend_string *name);
struct psi_builtin *psi_builtin_get(zend_string *name);
+uint16_t psi_swap16(uint16_t u);
+uint32_t psi_swap32(uint32_t u);
+uint64_t psi_swap64(uint64_t u);
+
#endif /* PSI_BUILTIN_H */