Refinement of src/main.c.

This commit is contained in:
Ruben Ayrapetyan
2014-07-23 19:08:06 +04:00
parent 0b76dfb6df
commit 26c00acd50
10 changed files with 260 additions and 228 deletions
+21 -7
View File
@@ -21,7 +21,7 @@
#include "globals.h"
typedef void FILE;
typedef void _FILE;
extern void* __memset (void *s, int c, size_t n);
extern int __memcmp (const void *s1, const void *s2, size_t n);
@@ -44,12 +44,26 @@ extern int __isalpha (int);
extern int __isdigit (int);
extern int __isxdigit (int);
extern FILE* __fopen(const char *, const char *);
extern int __fclose(FILE *);
extern void __rewind(FILE *);
extern size_t __fread(void *, size_t, size_t, FILE *);
extern size_t __fwrite(const void *, size_t, size_t, FILE *);
extern int __fprintf(FILE *, const char *, ...);
/**
* 'whence' argument of __fseek that identifies position
* the 'offset' argument is added to.
*/
typedef enum
{
__SEEK_SET, /**< relative to begin of file */
__SEEK_CUR, /**< relative to current position */
__SEEK_END /**< relative to end of file */
} _whence_t;
extern _FILE* __fopen(const char *, const char *);
extern int __fclose(_FILE *);
extern int __fseek(_FILE *, long offset, _whence_t);
extern long __ftell(_FILE *);
extern void __rewind(_FILE *);
extern size_t __fread(void *, size_t, size_t, _FILE *);
extern size_t __fwrite(const void *, size_t, size_t, _FILE *);
extern int __ferror(_FILE *);
extern int __fprintf(_FILE *, const char *, ...);
#define DBL_MANT_DIG ( 52)
#define DBL_DIG ( 10)
+1 -1
View File
@@ -28,4 +28,4 @@ void serializer_dump_opcode (const void *);
void serializer_rewrite_opcode (const int8_t, const void *);
#endif // SERIALIZER_H
#endif // SERIALIZER_H
+53 -17
View File
@@ -21,16 +21,8 @@
#include "jerry-libc.h"
#include <stdarg.h>
extern void __noreturn exit(int status);
extern FILE* fopen(const char *path, const char *mode);
extern int fclose(FILE *fp);
extern int rewind (FILE *);
extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
extern int vprintf (__const char *__restrict __format, __builtin_va_list __arg);
extern int vfprintf (FILE *stream, __const char *__restrict __format, __builtin_va_list __arg);
#include <stdio.h>
#include <stdlib.h>
/**
* printf
@@ -69,10 +61,10 @@ __exit (int status)
/**
* fopen
*
* @return FILE pointer - upon successful completion,
* @return _FILE pointer - upon successful completion,
* NULL - otherwise
*/
FILE*
_FILE*
__fopen(const char *path, /**< file path */
const char *mode) /**< file open mode */
{
@@ -82,7 +74,7 @@ __fopen(const char *path, /**< file path */
/** The rewind() function sets the file position
indicator for the stream pointed to by STREAM to the beginning of the file. */
void
__rewind (FILE *stream)
__rewind (_FILE *stream)
{
rewind (stream);
}
@@ -94,11 +86,46 @@ __rewind (FILE *stream)
* non-zero value - otherwise.
*/
int
__fclose(FILE *fp) /**< stream pointer */
__fclose(_FILE *fp) /**< stream pointer */
{
return fclose( fp);
} /* __fclose */
/**
* fseek
*/
int
__fseek(_FILE * fp, /**< stream pointer */
long offset, /**< offset */
_whence_t whence) /**< specifies position type
to add offset to */
{
int whence_real;
switch ( whence )
{
case __SEEK_SET:
whence_real = SEEK_SET;
break;
case __SEEK_CUR:
whence_real = SEEK_CUR;
break;
case __SEEK_END:
whence_real = SEEK_END;
break;
}
return fseek( fp, offset, whence_real);
} /* __fseek */
/**
* ftell
*/
long
__ftell(_FILE * fp) /**< stream pointer */
{
return ftell( fp);
} /* __ftell */
/**
* fread
*
@@ -108,7 +135,7 @@ size_t
__fread(void *ptr, /**< address of buffer to read to */
size_t size, /**< size of elements to read */
size_t nmemb, /**< number of elements to read */
FILE *stream) /**< stream pointer */
_FILE *stream) /**< stream pointer */
{
return fread(ptr, size, nmemb, stream);
} /* __fread */
@@ -122,18 +149,27 @@ size_t
__fwrite(const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */
FILE *stream) /**< stream pointer */
_FILE *stream) /**< stream pointer */
{
return fwrite(ptr, size, nmemb, stream);
} /* __fwrite */
/**
* ferror
*/
int
__ferror(_FILE * fp) /**< stream pointer */
{
return ferror( fp);
} /* __ferror */
/**
* fprintf
*
* @return number of characters printed
*/
int
__fprintf(FILE *stream, /**< stream pointer */
__fprintf(_FILE *stream, /**< stream pointer */
const char *format, /**< format string */
...) /**< parameters' values */
{
+1 -1
View File
@@ -17,7 +17,7 @@
#include "jerry-libc.h"
#include "opcodes.h"
FILE *dump;
_FILE *dump;
#define OPCODE_STR(op) \
#op,
+10 -5
View File
@@ -19,27 +19,32 @@
void
serializer_init (void)
{
JERRY_UNIMPLEMENTED();
}
uint8_t
serializer_dump_strings (const char *strings[] __unused, uint8_t size __unused)
serializer_dump_strings (const char *strings[], uint8_t size)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( strings, size);
}
void
serializer_dump_nums (const int nums[] __unused, uint8_t size __unused, uint8_t offset __unused, uint8_t strings_num __unused)
serializer_dump_nums (const int nums[], uint8_t size, uint8_t offset, uint8_t strings_num)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( nums, size, offset, strings_num);
}
void
serializer_dump_opcode (const void *opcode __unused)
serializer_dump_opcode (const void *opcode)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( opcode);
}
void
serializer_rewrite_opcode (const int8_t offset __unused, const void *opcode __unused)
serializer_rewrite_opcode (const int8_t offset, const void *opcode)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( offset, opcode);
}
TODO (Dump memory)
TODO (Dump memory)