IS_POSIX define
This commit is contained in:
parent
20fbb25aed
commit
1e34084b99
3 changed files with 15 additions and 10 deletions
16
debugger.cpp
16
debugger.cpp
|
@ -2,7 +2,8 @@
|
||||||
// Released under MIT license
|
// Released under MIT license
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#ifdef linux
|
#include "gen.h"
|
||||||
|
#if IS_POSIX
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -18,13 +19,12 @@
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "disk_backend.h"
|
#include "disk_backend.h"
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
#include "disk_backend_file.h"
|
#include "disk_backend_file.h"
|
||||||
#else
|
#else
|
||||||
#include "disk_backend_esp32.h"
|
#include "disk_backend_esp32.h"
|
||||||
#endif
|
#endif
|
||||||
#include "disk_backend_nbd.h"
|
#include "disk_backend_nbd.h"
|
||||||
#include "gen.h"
|
|
||||||
#include "loaders.h"
|
#include "loaders.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
@ -67,7 +67,7 @@ typedef enum { BE_NETWORK, BE_SD } disk_backend_t;
|
||||||
#if !defined(BUILD_FOR_RP2040)
|
#if !defined(BUILD_FOR_RP2040)
|
||||||
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > load_disk_configuration(console *const c)
|
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > load_disk_configuration(console *const c)
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
json_t *json = json_load_file("." NET_DISK_CFG_FILE, JSON_REJECT_DUPLICATES, &error);
|
json_t *json = json_load_file("." NET_DISK_CFG_FILE, JSON_REJECT_DUPLICATES, &error);
|
||||||
if (!json) {
|
if (!json) {
|
||||||
|
@ -147,7 +147,7 @@ std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *
|
||||||
|
|
||||||
bool save_disk_configuration(const std::string & nbd_host, const int nbd_port, const std::optional<std::string> & tape_file, const disk_type_t dt, console *const cnsl)
|
bool save_disk_configuration(const std::string & nbd_host, const int nbd_port, const std::optional<std::string> & tape_file, const disk_type_t dt, console *const cnsl)
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
json_t *json = json_object();
|
json_t *json = json_object();
|
||||||
|
|
||||||
json_object_set(json, "NBD-host", json_string(nbd_host.c_str()));
|
json_object_set(json, "NBD-host", json_string(nbd_host.c_str()));
|
||||||
|
@ -297,7 +297,7 @@ std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *
|
||||||
// RK05, RL02 files
|
// RK05, RL02 files
|
||||||
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > select_disk_files(console *const c)
|
std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *>, std::string> > select_disk_files(console *const c)
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
c->put_string_lf("Files in current directory: ");
|
c->put_string_lf("Files in current directory: ");
|
||||||
#else
|
#else
|
||||||
c->debug("MISO: %d", int(MISO));
|
c->debug("MISO: %d", int(MISO));
|
||||||
|
@ -377,7 +377,7 @@ std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *
|
||||||
|
|
||||||
bool can_open_file = false;
|
bool can_open_file = false;
|
||||||
|
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
struct stat st { };
|
struct stat st { };
|
||||||
can_open_file = stat(selected_file.c_str(), &st) == 0;
|
can_open_file = stat(selected_file.c_str(), &st) == 0;
|
||||||
#else
|
#else
|
||||||
|
@ -391,7 +391,7 @@ std::optional<std::tuple<std::vector<disk_backend *>, std::vector<disk_backend *
|
||||||
if (disk_type.value() == DT_TAPE)
|
if (disk_type.value() == DT_TAPE)
|
||||||
return { { { }, { }, selected_file } };
|
return { { { }, { }, selected_file } };
|
||||||
|
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
disk_backend *temp = new disk_backend_file(selected_file);
|
disk_backend *temp = new disk_backend_file(selected_file);
|
||||||
#else
|
#else
|
||||||
disk_backend *temp = new disk_backend_esp32(selected_file);
|
disk_backend *temp = new disk_backend_esp32(selected_file);
|
||||||
|
|
3
gen.h
3
gen.h
|
@ -12,3 +12,6 @@ typedef enum { d_space, i_space } d_i_space_t;
|
||||||
typedef enum { wm_word = 0, wm_byte = 1 } word_mode_t;
|
typedef enum { wm_word = 0, wm_byte = 1 } word_mode_t;
|
||||||
|
|
||||||
typedef enum { rm_prev, rm_cur } rm_selection_t;
|
typedef enum { rm_prev, rm_cur } rm_selection_t;
|
||||||
|
|
||||||
|
#define IS_POSIX (defined(linux) || defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)))
|
||||||
|
#define IS_UP (!(IS_POSIX)) /* is microprocessor */
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// (C) 2018-2023 by Folkert van Heusden
|
// (C) 2018-2024 by Folkert van Heusden
|
||||||
// Released under MIT license
|
// Released under MIT license
|
||||||
|
|
||||||
|
#include "gen.h"
|
||||||
|
|
||||||
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "rp2040.h"
|
#include "rp2040.h"
|
||||||
|
@ -165,7 +167,7 @@ void set_thread_name(std::string name)
|
||||||
|
|
||||||
std::string get_thread_name()
|
std::string get_thread_name()
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#if IS_POSIX
|
||||||
char buffer[16 + 1] { };
|
char buffer[16 + 1] { };
|
||||||
pthread_getname_np(pthread_self(), buffer, sizeof buffer);
|
pthread_getname_np(pthread_self(), buffer, sizeof buffer);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue