Fix build for C99

Signed-off-by: Mahyar Koshkouei <mahyar.koshkouei@gmail.com>
This commit is contained in:
Mahyar Koshkouei 2018-02-24 15:13:32 +00:00
parent 665aa372e0
commit a8f84fa9b4
2 changed files with 16 additions and 8 deletions

View File

@ -112,15 +112,13 @@ else
endif endif
OBJECTS := mpv-libretro.o OBJECTS := mpv-libretro.o
LDFLAGS += -lmpv LDFLAGS += -lmpv -lm
CFLAGS += -Wall -pedantic -std=c99 CFLAGS += -Wall -pedantic -std=c99 -I.
ifneq (,$(findstring gles,$(platform))) ifneq (,$(findstring gles,$(platform)))
LDFLAGS += -ldl LDFLAGS += -ldl
endif endif
LDFLAGS += -lm
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)

View File

@ -14,13 +14,16 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* Required for nanosleep */
#define _POSIX_C_SOURCE 199309L
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <time.h>
#ifdef HAVE_OPENGLES #ifdef HAVE_OPENGLES
#include <dlfcn.h> #include <dlfcn.h>
@ -336,7 +339,8 @@ static void context_reset(void)
"playback-time", MPV_FORMAT_INT64, &playback_time) < 0) "playback-time", MPV_FORMAT_INT64, &playback_time) < 0)
{ {
/* Garbage fix to overflowing log */ /* Garbage fix to overflowing log */
usleep(10); static struct timespec ts = { 0, 10 * 1000 };
nanosleep(&ts, NULL);
} }
/* TODO #2: Check for the highest samplerate in audio stream, and use that. /* TODO #2: Check for the highest samplerate in audio stream, and use that.
@ -610,7 +614,13 @@ bool retro_load_game(const struct retro_game_info *info)
/* Copy the file path to a global variable as we need it in context_reset() /* Copy the file path to a global variable as we need it in context_reset()
* where mpv is initialised. * where mpv is initialised.
*/ */
filepath = strdup(info->path); if((filepath = malloc(strlen(info->path)+1)) == NULL)
{
log_cb(RETRO_LOG_ERROR, "Unable to allocate memory for filepath\n");
return false;
}
strcpy(filepath,info->path);
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);