Skip to content

Commit

Permalink
Definitions cleanup (#8)
Browse files Browse the repository at this point in the history
* Moved definitions from CLI to files (__linux__)

* Moved ARM definition to a file
  • Loading branch information
orenskl authored Jan 15, 2024
1 parent abedb9b commit 2d65871
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
"cldc/src/javaapi/device",
"examples/src"
],
"cSpell.words": [
"Pico"
],
}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ target_include_directories(pjvm PRIVATE
)

if (${TARGET} STREQUAL PICO)
target_compile_definitions(pjvm PRIVATE GCC PICO ARM SUPPORTS_MONOTONIC_CLOCK=1)
target_compile_definitions(pjvm PRIVATE PICO)
endif()
if (${TARGET} STREQUAL LINUX)
target_compile_definitions(pjvm PRIVATE GCC LINUX SUPPORTS_MONOTONIC_CLOCK=0 PRODUCT)
target_compile_definitions(pjvm PRIVATE PRODUCT)
target_compile_options(pjvm PRIVATE -m32 -fpermissive)
target_link_options(pjvm PRIVATE -m32)
endif()
Expand Down
15 changes: 2 additions & 13 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,7 @@ target_include_directories(jvm PRIVATE
${JVM_INCLUDE_OS_DIRS}
)

target_compile_definitions(jvm PRIVATE
GCC
REQUIRES_JVMCONFIG_H=1
HARDWARE_LITTLE_ENDIAN=1
HOST_LITTLE_ENDIAN=1
JVM_RELEASE_VERSION="${LIBJVM_VERSION}"
JVM_BUILD_VERSION="internal"
JVM_NAME="Pico JVM"
ROMIZING=1
PRODUCT
)
target_compile_definitions(jvm PRIVATE JVM_RELEASE_VERSION="${LIBJVM_VERSION}" ROMIZING=1 PRODUCT)

set(JVM_COMPILE_OPTIONS -Wuninitialized
-Wreturn-type
Expand All @@ -448,12 +438,11 @@ set(JVM_COMPILE_OPTIONS -Wuninitialized
)

if (${TARGET} STREQUAL PICO)
target_compile_definitions(jvm PRIVATE PICO ARM SUPPORTS_MONOTONIC_CLOCK=1)
target_compile_definitions(jvm PRIVATE PICO)
target_compile_options(jvm PRIVATE -mcpu=cortex-m0plus -mthumb ${JVM_COMPILE_OPTIONS})
endif()

if (${TARGET} STREQUAL LINUX)
target_compile_definitions(jvm PRIVATE LINUX SUPPORTS_MONOTONIC_CLOCK=0)
target_compile_options(jvm PRIVATE -m32 ${JVM_COMPILE_OPTIONS})
endif()

Expand Down
4 changes: 1 addition & 3 deletions lib/src/vm/os/linux/BuildFlags_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@
#endif

// The default Linux port supports monotonic clock
#ifndef SUPPORTS_MONOTONIC_CLOCK
#error "SUPPORTS_MONOTONIC_CLOCK must be defined in jvm.make"
#endif
#define SUPPORTS_MONOTONIC_CLOCK 0

#define ENABLE_BKPT_FATAL

Expand Down
4 changes: 4 additions & 0 deletions lib/src/vm/os/pico/BuildFlags_pico.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@

#define SUPPORTS_DIRECTORIES 0

#define SUPPORTS_MONOTONIC_CLOCK 1

#define ARM 1

4 changes: 2 additions & 2 deletions lib/src/vm/share/ROM/SourceROMOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void ROMOptimizer::read_config_file(JVM_SINGLE_ARG_TRAPS) {
}

void ROMOptimizer::read_config_file(const JvmPathChar* config_file JVM_TRAPS) {
#if defined(WIN32) || defined(LINUX)
#if defined(WIN32) || defined(__linux__)
char buff[1024];
OsFile_Handle f = OsFile_open(config_file, "r");
if (f == NULL) {
Expand Down Expand Up @@ -948,7 +948,7 @@ void ROMOptimizer::process_config_line(char* s JVM_TRAPS) {
}

void ROMOptimizer::include_config_file(const char *config_file JVM_TRAPS) {
#if defined(WIN32) || defined(LINUX)
#if defined(WIN32) || defined(__linux__)

#if USE_UNICODE_FOR_FILENAMES
JvmPathChar fn_config_file[1024+1];
Expand Down
4 changes: 2 additions & 2 deletions lib/src/vm/share/natives/BSDSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" {

#if USE_BSD_SOCKET

#if defined(LINUX) || defined (CYGWIN)
#if defined(__linux__) || defined (CYGWIN)
#define USE_UNISTD_SOCKETS 1
#else
#if defined(WIN32) || defined(UNDER_CE)
Expand Down Expand Up @@ -83,7 +83,7 @@ extern "C" {
#endif
#define init_sockets()
#define closesocket(x) jvm_close(x)
#endif // LINUX
#endif // __linux__

#if USE_WINSOCK_SOCKETS
#undef FIELD_OFFSET
Expand Down
2 changes: 1 addition & 1 deletion lib/src/vm/share/runtime/OsFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef _OSFILE_HPP_
#define _OSFILE_HPP_

#ifdef LINUX
#ifdef __linux__
#include "OsFile_linux.hpp"
#endif
#ifdef PICO
Expand Down
13 changes: 8 additions & 5 deletions lib/src/vm/share/utilities/BuildFlags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@

// AZZERT Add assertion code (debug build)

// LINUX Target OS is Linux

// CROSS_GENERATOR In an loopgen or romgen build

// PRODUCT In a product target build
Expand All @@ -86,7 +84,7 @@
#ifndef _BUILDFLAGS_HPP_
#define _BUILDFLAGS_HPP_

#ifdef LINUX
#ifdef __linux__
#include "BuildFlags_linux.hpp"
#endif
#ifdef PICO
Expand All @@ -97,6 +95,11 @@
#define CROSS_GENERATOR 0
#endif

/* Currently we support only LE targets (Linux x86, Raspberry Pi Pico) */
#ifndef HARDWARE_LITTLE_ENDIAN
#define HARDWARE_LITTLE_ENDIAN 1
#endif

//============================================================================
// *** NOTE: the formatting of this block is important. Do not change. ***
//
Expand Down Expand Up @@ -852,14 +855,14 @@
#endif

// Some system header files defines ARM to be blank, which doesn't
// work with the way we use macros (e.g., #if ARM && LINUX). So
// work with the way we use macros (e.g., #if ARM && __linux__). So
// let's change it to something more pleasant.
#ifdef ARM
# undef ARM
# define ARM 1
#endif

#if defined(LINUX) && defined(ARM) && !ENABLE_INTERPRETER_GENERATOR && !CROSS_GENERATOR
#if defined(__linux__) && defined(ARM) && !ENABLE_INTERPRETER_GENERATOR && !CROSS_GENERATOR
# define ARM_EXECUTABLE 1
#else
# define ARM_EXECUTABLE 0
Expand Down
2 changes: 1 addition & 1 deletion lib/src/vm/share/utilities/BytecodeHistogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int __cdecl compare_entries(const void* e1, const void* e2) {
return delta < 0 ? -1 : (delta == 0 ? 0 : 1);
}

#ifdef LINUX
#ifdef __linux__
#define FLL "%14lld"
#else
#define FLL "%14I64d"
Expand Down
2 changes: 1 addition & 1 deletion lib/src/vm/share/utilities/GlobalDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const char * name_for(BasicType type) {

void global_breakpoint() {
#if defined(__GNUC__)
#ifdef LINUX
#ifdef __linux__
BREAKPOINT;
#else
// IMPL_NOTE: move this into OS class
Expand Down
2 changes: 1 addition & 1 deletion lib/src/vm/share/utilities/GlobalDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#include "kni.h"
#include "ROMImage.hpp"
#include "GlobalDefinitions_gcc.hpp"
#ifdef LINUX
#ifdef __linux__
#include "Globals_linux.hpp"
#endif
#ifdef PICO
Expand Down
4 changes: 2 additions & 2 deletions lib/src/vm/share/utilities/GlobalDefinitions_gcc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# include <ctype.h>
# include <string.h>
#if (defined(LINUX) || defined(PICO)) && !defined(SOLARIS)
#if (defined(__linux__) || defined(PICO)) && !defined(SOLARIS)
# include <stdint.h>
#endif
# include <stdarg.h>
Expand Down Expand Up @@ -178,7 +178,7 @@ const jlong max_jlong = ~min_jlong;
//---------------------------------------------------------------------------

// Portability macros
#if defined(LINUX) || defined(PICO)
#if defined(__linux__) || defined(PICO)
#define __cdecl
#define _cdecl
#endif
Expand Down
2 changes: 1 addition & 1 deletion lib/src/vm/share/utilities/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG,DECLARE_PRODUCT_FLAG,DECLARE_ALWAYS_FLAG)
#endif

#ifndef JVM_NAME
#define JVM_NAME "CLDC VM"
#define JVM_NAME "Pico JVM"
#endif

#endif /* _GLOBALS_HPP_ */
2 changes: 1 addition & 1 deletion lib/src/vm/share/utilities/PairHistogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int __cdecl pair_compare_entries(const void* e1, const void* e2) {
return delta < 0 ? -1 : (delta == 0 ? 0 : 1);
}

#ifdef LINUX
#ifdef __linux__
#define FLL "%14lld"
#else
#define FLL "%14I64d"
Expand Down
2 changes: 1 addition & 1 deletion lib/tools/preverify/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ add_executable(preverify
src/sys_support.c
)

target_compile_definitions(preverify PRIVATE UNIX LINUX JAVAVERIFY TRIMMED ARCH=i386)
target_compile_definitions(preverify PRIVATE UNIX JAVAVERIFY TRIMMED ARCH=i386)
target_include_directories(preverify PRIVATE src)
target_compile_options(preverify PRIVATE)
2 changes: 1 addition & 1 deletion lib/tools/preverify/src/sys_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ typedef void * stackp_t;
int sysThreadBootstrap(sys_thread_t **, void *);
void sysThreadInitializeSystemThreads(void);

#ifndef LINUX
#ifndef __linux__
int sysThreadCreate(long, uint_t flags, void *(*)(void *),
sys_thread_t **, void *);
#else
Expand Down
6 changes: 3 additions & 3 deletions lib/tools/preverify/src/typedefs_md.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ typedef long int32_t;
#endif /* !defined(_ILP32) && !defined(_LP64) */
#endif /* SOLARIS2 */

#ifdef LINUX
#ifdef __linux__
#ifndef _UINT64_T
#define _UINT64_T
typedef unsigned long long uint64_t;
#define _UINT32_T
typedef unsigned long uint32_t;
#endif
#endif /* LINUX */
#endif /* __linux__ */

#ifdef DARWIN
#ifndef _UINT64_T
Expand Down Expand Up @@ -149,7 +149,7 @@ extern void ll2str(int64_t a, char *s, char *limit);
#include <sys/byteorder.h>
#endif

#ifdef LINUX
#ifdef __linux__
#include <asm/byteorder.h>
#endif

Expand Down
14 changes: 1 addition & 13 deletions lib/tools/romgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,7 @@ target_include_directories(romgen PRIVATE
../../src/vm/os/linux
)

target_compile_definitions(romgen PRIVATE
-DSUPPORTS_MONOTONIC_CLOCK=0
-DAZZERT
-D_DEBUG
-DGCC
-DLINUX
-DREQUIRES_JVMCONFIG_H=1
-DHARDWARE_LITTLE_ENDIAN=1
-DHOST_LITTLE_ENDIAN=1
JVM_RELEASE_VERSION="${ROMGEN_VERSION}"
JVM_BUILD_VERSION="internal"
JVM_NAME="Pico JVM"
)
target_compile_definitions(romgen PRIVATE AZZERT _DEBUG JVM_RELEASE_VERSION="${ROMGEN_VERSION}")

target_compile_options(romgen PRIVATE -m32
-Wuninitialized
Expand Down

0 comments on commit 2d65871

Please sign in to comment.