#define MAX_PACKET_SIZE_FS 64
#define MAX_PACKET_SIZE_HS 512
-#define cpu_to_le16(x) htole16(x)
-#define cpu_to_le32(x) htole32(x)
+/*
+ * cpu_to_le16/32 are used when initializing structures, a context where a
+ * function call is not allowed. To solve this, we code cpu_to_le16/32 in a way
+ * that allows them to be used when initializing structures.
+ */
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define cpu_to_le16(x) (x)
+#define cpu_to_le32(x) (x)
+#else
+#define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+#define cpu_to_le32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
extern struct sdb_usb_descs {
struct usb_functionfs_descs_head header;
void start_device_log(void)
{
int fd;
- char path[PATH_MAX] = {0, };
+ char path[2*PATH_MAX] = {0, };
char path_folder[PATH_MAX] = {0, };
char path_file[PATH_MAX] = {0, };
struct tm now;
// send the "emulator" request to sdbserver
static void* notify_sdbd_startup_thread(void* ptr) {
char buffer[512];
- char request[512];
+ char request[500];
SdbdCommandlineArgs *sdbd_args = &sdbd_commandline_args; // alias