summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-27 12:38:25 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-27 12:38:25 +0000
commit2c2e261648d5ae1befe5c4f269a655cc06b6e1e9 (patch)
tree16ea536a547deb252276c29d34eeee08f029866f /firmware
parent79798ff5f30dea7419f360e197763abb3b46259a (diff)
downloadrockbox-2c2e261648d5ae1befe5c4f269a655cc06b6e1e9.tar.gz
rockbox-2c2e261648d5ae1befe5c4f269a655cc06b6e1e9.tar.bz2
rockbox-2c2e261648d5ae1befe5c4f269a655cc06b6e1e9.zip
Use system headers a bit more: use host's fcntl.h for O_RDONLY etc.
Removes the need to fix up those in the simulator. Also work around some posix-mingw incompatibilities (e.g. getcwd()). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27904 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/load_code.h8
-rw-r--r--firmware/include/file.h29
-rw-r--r--firmware/libc/include/fcntl.h40
-rw-r--r--firmware/load_code.c8
4 files changed, 59 insertions, 26 deletions
diff --git a/firmware/export/load_code.h b/firmware/export/load_code.h
index f4fa8f9b46..e37af786df 100644
--- a/firmware/export/load_code.h
+++ b/firmware/export/load_code.h
@@ -42,7 +42,13 @@ static inline void lc_close(void *handle) { (void)handle; }
/* don't call these directly for loading code
* they're to be wrapped by platform specific functions */
-extern void *_lc_open(const char *filename, char *buf, size_t buf_size);
+#ifdef WIN32
+/* windows' LoadLibrary can only handle ucs2, no utf-8 */
+#define _lc_open_char wchar_t
+#else
+#define _lc_open_char char
+#endif
+extern void *_lc_open(const _lc_open_char *filename, char *buf, size_t buf_size);
extern void *_lc_get_header(void *handle);
extern void _lc_close(void *handle);
diff --git a/firmware/include/file.h b/firmware/include/file.h
index a9d1d05a11..7799f3d625 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -25,31 +25,19 @@
#include <sys/types.h>
#include "config.h"
#include "gcc_extensions.h"
+#include <fcntl.h>
+#ifdef WIN32
+/* this has SEEK_SET et al */
+#include <stdio.h>
+#endif
+
#undef MAX_PATH /* this avoids problems when building simulator */
#define MAX_PATH 260
#define MAX_OPEN_FILES 11
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#define O_CREAT 4
-#define O_APPEND 8
-#define O_TRUNC 0x10
-#endif
-
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED) && !defined(PLUGIN) && !defined(CODEC)
+#if !defined(PLUGIN) && !defined(CODEC)
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
#define open(x, ...) sim_open(x, __VA_ARGS__)
#define creat(x,m) sim_creat(x,m)
#define remove(x) sim_remove(x)
@@ -96,4 +84,5 @@ extern int ftruncate(int fd, off_t length);
extern off_t filesize(int fd);
extern int release_files(int volume);
int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
+#endif /* !CODEC && !PLUGIN */
#endif
diff --git a/firmware/libc/include/fcntl.h b/firmware/libc/include/fcntl.h
new file mode 100644
index 0000000000..34740c9ca2
--- /dev/null
+++ b/firmware/libc/include/fcntl.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Björn Stenberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __FCNTL_H__
+#define __FCNTL_H__
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#define O_WRONLY 1
+#define O_RDWR 2
+#define O_CREAT 4
+#define O_APPEND 8
+#define O_TRUNC 0x10
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#endif /* __FCNTL_H__ */
diff --git a/firmware/load_code.c b/firmware/load_code.c
index 9e8e71f9af..75bac8b2ac 100644
--- a/firmware/load_code.c
+++ b/firmware/load_code.c
@@ -80,13 +80,12 @@ static inline char *_dlerror(void)
#else
/* unix */
#include <dlfcn.h>
-#define O_BINARY 0
#endif
#include <stdio.h>
#include "rbpaths.h"
#include "general.h"
-void * _lc_open(const char *filename, char *buf, size_t buf_size)
+void * _lc_open(const _lc_open_char *filename, char *buf, size_t buf_size)
{
(void)buf;
(void)buf_size;
@@ -116,14 +115,13 @@ void *lc_open_from_mem(void *addr, size_t blob_size)
char name[MAX_PATH];
const char *_name = get_user_file_path(ROCKBOX_DIR, NEED_WRITE, name, sizeof(name));
snprintf(temp_filename, sizeof(temp_filename),
- "%slibtemp_binary_%d.dll", _name, i);
+ "%s/libtemp_binary_%d.dll", _name, i);
#endif
- fd = open(temp_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0766);
+ fd = open(temp_filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
if (fd >= 0)
break; /* Created a file ok */
}
- DEBUGF("Creating %s\n", temp_filename);
if (fd < 0)
{
DEBUGF("open failed\n");