(PSP/PS3) Resolve namespace conflict with memcpy16 for PS3 -
[picodrive.git] / platform / libretro.c
index 67b4369..8cda278 100644 (file)
@@ -11,7 +11,9 @@
 #include <stdarg.h>
 #include <string.h>
 #ifndef _WIN32
+#ifndef NO_MMAP
 #include <sys/mman.h>
+#endif
 #else
 #include <io.h>
 #include <windows.h>
@@ -161,6 +163,30 @@ static void munmap(void *addr, size_t length)
        UnmapViewOfFile(addr);
        /* ruh-ro, we leaked handle from CreateFileMapping() ... */
 }
+#elif defined(NO_MMAP)
+#define        PROT_EXEC   0x04
+#define MAP_FAILED 0
+#define PROT_READ 0
+#define PROT_WRITE 0
+#define MAP_PRIVATE 0
+#define MAP_ANONYMOUS 0
+
+void* mmap(void *desired_addr, size_t len, int mmap_prot, int mmap_flags, int fildes, size_t off)
+{
+   return malloc(len);
+}
+
+void munmap(void *base_addr, size_t len)
+{
+   free(base_addr);
+}
+
+int mprotect(void *addr, size_t len, int prot)
+{
+   /* stub - not really needed at this point since this codepath has no dynarecs */
+   return 0;
+}
+
 #endif
 
 #ifndef MAP_ANONYMOUS
@@ -263,9 +289,13 @@ void emu_32x_startup(void)
 
 void lprintf(const char *fmt, ...)
 {
+   char buffer[256];
+   va_list ap;
+   va_start(ap, fmt);
+   vsprintf(buffer, fmt, ap);
    /* TODO - add 'level' param for warning/error messages? */
    if (log_cb)
-      log_cb(RETRO_LOG_INFO, fmt);
+      log_cb(RETRO_LOG_INFO, "%s\n", fmt);
 }
 
 /* libretro */
@@ -870,9 +900,10 @@ void retro_init(void)
        level = 0;
        environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
 
-   environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log);
-   if (log.log)
+   if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
       log_cb = log.log;
+   else
+      log_cb = NULL;
 
        environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control);