1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
diff --git a/apps/audio_path.c b/apps/audio_path.c
index e928880..22630f1 100644
--- a/apps/audio_path.c
+++ b/apps/audio_path.c
@@ -42,7 +42,7 @@
 #endif
 #endif

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & CONFIG_NATIVE)

 #ifdef AUDIO_CPU_BOOST
 static void audio_cpu_boost(bool state)
@@ -115,7 +115,7 @@ int audio_get_spdif_sample_rate(void)
 } /* audio_get_spdif_sample_rate */
 #endif /* HAVE_SPDIF_IN */

-#else /* SIMULATOR */
+#else /* PLATFORM_HOSTED */

 /** Sim stubs **/

@@ -144,4 +144,4 @@ int audio_get_spdif_sample_rate(void)
 } /* audio_get_spdif_sample_rate */
 #endif /* HAVE_SPDIF_IN */

-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */
diff --git a/apps/buffering.c b/apps/buffering.c
index 8a6418f..c2cecdd 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1488,7 +1488,7 @@ void buffering_thread(void)
                 base_handle_id = (int)ev.data;
                 break;

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
             case SYS_USB_CONNECTED:
                 LOGFQUEUE("buffering < SYS_USB_CONNECTED");
                 usb_acknowledge(SYS_USB_CONNECTED_ACK);
diff --git a/apps/codecs.c b/apps/codecs.c
index 46d9223..22e692c 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -54,20 +54,20 @@
 #define LOGF_ENABLE
 #include "logf.h"

-#ifdef SIMULATOR
-#define PREFIX(_x_) sim_ ## _x_
-#else
-#define PREFIX
-#endif
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)

-#ifdef SIMULATOR
+#define PREFIX(_x_) sim_ ## _x_
 #if CONFIG_CODEC == SWCODEC
 unsigned char codecbuf[CODEC_SIZE];
 #endif
 void *sim_codec_load_ram(char* codecptr, int size, void **pd);
 void sim_codec_close(void *pd);
-#else
+
+#else /* !PLATFORM_HOSTED */
+
+#define PREFIX
 #define sim_codec_close(x)
+
 #endif

 size_t codec_size;
@@ -77,7 +77,7 @@ extern void* plugin_get_audio_buffer(size_t *buffer_size);
 #undef open
 static int open(const char* pathname, int flags, ...)
 {
-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
     int fd;
     if (flags & O_CREAT)
     {
@@ -201,7 +201,7 @@ static int codec_load_ram(int size, struct codec_api *api)
 {
     struct codec_header *hdr;
     int status;
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     hdr = (struct codec_header *)codecbuf;

     if (size <= (signed)sizeof(struct codec_header)
@@ -220,7 +220,7 @@ static int codec_load_ram(int size, struct codec_api *api)

     codec_size = hdr->end_addr - codecbuf;

-#else /* SIMULATOR */
+#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
     void *pd;

     hdr = sim_codec_load_ram(codecbuf, size, &pd);
@@ -241,7 +241,7 @@ static int codec_load_ram(int size, struct codec_api *api)

     codec_size = codecbuf - codecbuf;

-#endif /* SIMULATOR */
+#endif /* CONFIG_PLATFORM */
     if (hdr->api_version > CODEC_API_VERSION
         || hdr->api_version < CODEC_MIN_API_VERSION) {
         sim_codec_close(pd);
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 1288d9a..74c6a47 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -53,7 +53,7 @@
 #include "lcd-remote.h"
 #include "crc32.h"
 #include "logf.h"
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #include "disk.h"
 #include "adc.h"
 #include "power.h"
@@ -371,7 +371,7 @@ static bool dbg_buffering_thread(void)

             screens[i].putsf(0, line++, "handle count: %d", (int)d.num_handles);

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
             screens[i].putsf(0, line++, "cpu freq: %3dMHz",
                              (int)((FREQ + 500000) / 1000000));
 #endif
@@ -758,7 +758,7 @@ static bool dbg_hw_info(void)
 #endif /* !HAVE_LCD_BITMAP */
 #endif /* !SIMULATOR */

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 static const char* dbg_partitions_getname(int selected_item, void *data,
                                           char *buffer, size_t buffer_len)
 {
@@ -786,7 +786,7 @@ bool dbg_partitions(void)
     info.get_name = dbg_partitions_getname;
     return simplelist_show_list(&info);
 }
-#endif
+#endif /* PLATFORM_NATIVE */

 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
 static bool dbg_spdif(void)
@@ -928,7 +928,7 @@ static bool dbg_spdif(void)
         lcd_putsf(0, line++, "Clock accuracy: %d", x);
         line++;

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
         lcd_putsf(0, line++, "Measured freq: %ldHz",
                  spdif_measure_frequency());
 #endif
@@ -950,7 +950,7 @@ static bool dbg_spdif(void)
 }
 #endif /* CPU_COLDFIRE */

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #ifdef HAVE_LCD_BITMAP
  /* button definitions */
 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
@@ -1322,9 +1322,9 @@ bool dbg_ports(void)
     return false;
 }
 #endif /* !HAVE_LCD_BITMAP */
-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */

-#if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
+#if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
 static bool dbg_pcf(void)
 {
     int line;
@@ -1411,7 +1411,7 @@ static bool dbg_cpufreq(void)
 }
 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */

-#if defined(HAVE_TSC2100) && !defined(SIMULATOR)
+#if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #include "tsc2100.h"
 static char *itob(int n, int len)
 {
@@ -1481,7 +1481,7 @@ static bool tsc2100_debug(void)
     return simplelist_show_list(&info);
 }
 #endif
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #ifdef HAVE_LCD_BITMAP
 /*
  * view_battery() shows a automatically scaled graph of the battery voltage
@@ -1779,7 +1779,7 @@ static bool view_battery(void)
 #endif /* HAVE_LCD_BITMAP */
 #endif

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)

 #if (CONFIG_STORAGE & STORAGE_MMC)
@@ -2100,7 +2100,7 @@ static bool dbg_disk_info(void)
     info.scroll_all = true;
     return simplelist_show_list(&info);
 }
-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */

 #ifdef HAVE_DIRCACHE
 static int dircache_callback(int btn, struct gui_synclist *lists)
@@ -2651,10 +2651,10 @@ static const struct the_menu_item menuitems[] = {
     || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2
         { "View I/O ports", dbg_ports },
 #endif
-#if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
+#if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "View PCF registers", dbg_pcf },
 #endif
-#if defined(HAVE_TSC2100) && !defined(SIMULATOR)
+#if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "TSC2100 debug", tsc2100_debug },
 #endif
 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
@@ -2668,18 +2668,18 @@ static const struct the_menu_item menuitems[] = {
 #endif
         { "View OS stacks", dbg_os },
 #ifdef HAVE_LCD_BITMAP
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "View battery", view_battery },
 #endif
         { "Screendump", dbg_screendump },
 #endif
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "View HW info", dbg_hw_info },
 #endif
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "View partitions", dbg_partitions },
 #endif
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
         { "View disk info", dbg_disk_info },
 #if (CONFIG_STORAGE & STORAGE_ATA)
         { "Dump ATA identify info", dbg_identify_info},
diff --git a/apps/filetree.c b/apps/filetree.c
index 1faf4c9..460ab9e 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -597,7 +597,7 @@ int ft_enter(struct tree_context* c)
                 break;
 #endif

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
                 /* firmware file */
             case FILE_ATTR_MOD:
                 splash(0, ID2P(LANG_WAIT));
diff --git a/apps/main.c b/apps/main.c
index e8043a7..bc49400 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -115,6 +115,8 @@

 #ifdef SIMULATOR
 #include "sim_tasks.h"
+#endif
+#ifdef HAVE_SDL
 #include "system-sdl.h"
 #endif

@@ -313,7 +315,7 @@ static void init_tagcache(void)
 }
 #endif

-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)

 static void init(void)
 {
diff --git a/apps/misc.c b/apps/misc.c
index 747abe0..2895576 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -251,7 +251,7 @@ static void system_restore(void)

 static bool clean_shutdown(void (*callback)(void *), void *parameter)
 {
-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
     (void)callback;
     (void)parameter;
     bookmark_autobookmark(false);
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index e9102b2..ebc31fb 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -30,7 +30,7 @@
 /* Define LOGF_ENABLE to enable logf output in this file */
 /*#define LOGF_ENABLE*/
 #include "logf.h"
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 #include "cpu.h"
 #endif
 #include <string.h>
diff --git a/apps/playback.c b/apps/playback.c
index 0be45b0..9fb0a76 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -468,7 +468,7 @@ unsigned char *audio_get_recording_buffer(size_t *buffer_size)

 bool audio_load_encoder(int afmt)
 {
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     const char *enc_fn = get_codec_filename(afmt | CODEC_TYPE_ENCODER);
     if (!enc_fn)
         return false;
@@ -493,7 +493,7 @@ bool audio_load_encoder(int afmt)

 void audio_remove_encoder(void)
 {
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     /* force encoder codec unload (if currently loaded) */
     if (ci.enc_codec_loaded <= 0)
         return;
@@ -2010,7 +2010,7 @@ static void audio_thread(void)
                 LOGFQUEUE("audio < Q_AUDIO_TRACK_CHANGED");
                 audio_finalise_track_change();
                 break;
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
             case SYS_USB_CONNECTED:
                 LOGFQUEUE("audio < SYS_USB_CONNECTED");
                 if (playing)
diff --git a/apps/playlist.c b/apps/playlist.c
index 485601c..4a6db88 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1318,7 +1318,7 @@ static void playlist_thread(void)
                 dirty_pointers = false;
                 break ;

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
             case SYS_USB_CONNECTED:
                 usb_acknowledge(SYS_USB_CONNECTED_ACK);
                 usb_wait_for_disconnect(&playlist_queue);
diff --git a/apps/plugin.c b/apps/plugin.c
index d626ef6..dba5e61 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -57,7 +57,7 @@
 #include "usbstack/usb_hid.h"
 #endif

-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
 #define PREFIX(_x_) sim_ ## _x_
 #else
 #define PREFIX
@@ -72,7 +72,7 @@
 static unsigned int open_files;
 #endif

-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
 static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
 void *sim_plugin_load(char *plugin, void **pd);
 void sim_plugin_close(void *pd);
@@ -157,7 +157,7 @@ static const struct plugin_api rockbox_api = {
     lcd_yuv_set_options,
 #endif
 #endif /* MEMORYSIZE > 2 */
-#elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
+#elif (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
     lcd_blit_mono,
     lcd_blit_grey_phase,
 #endif /* LCD_DEPTH */
@@ -366,7 +366,7 @@ static const struct plugin_api rockbox_api = {
 #endif

     reset_poweroff_timer,
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     system_memory_guard,
     &cpu_frequency,

@@ -377,7 +377,7 @@ static const struct plugin_api rockbox_api = {
     cpu_boost,
 #endif
 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */
 #ifdef HAVE_SCHEDULER_BOOSTCTRL
     trigger_cpu_boost,
     cancel_cpu_boost,
@@ -415,7 +415,7 @@ static const struct plugin_api rockbox_api = {
     remove_event,
     send_event,

-#ifdef SIMULATOR
+#ifdef (CONFIG_PLATFORM & PLATFORM_HOSTED)
     /* special simulator hooks */
 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
     sim_lcd_ex_init,
@@ -437,7 +437,7 @@ static const struct plugin_api rockbox_api = {
     memset,
     memcpy,
     memmove,
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     _ctype_,
 #endif
     atoi,
@@ -467,7 +467,7 @@ static const struct plugin_api rockbox_api = {
 #ifdef AUDIOHW_HAVE_EQ
     sound_enum_hw_eq_band_setting,
 #endif
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     mp3_play_data,
     mp3_play_pause,
     mp3_play_stop,
@@ -589,7 +589,7 @@ static const struct plugin_api rockbox_api = {
     battery_level,
     battery_level_safe,
     battery_time,
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     battery_voltage,
 #endif
 #if CONFIG_CHARGING
@@ -603,7 +603,7 @@ static const struct plugin_api rockbox_api = {
 #endif

     /* misc */
-#if !defined(SIMULATOR)
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     &errno,
 #endif
     srand,
@@ -727,15 +727,15 @@ int plugin_load(const char* plugin, const void* parameter)
 {
     int rc, i;
     struct plugin_header *hdr;
-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
     void *pd;
-#else /* !SIMULATOR */
+#else /* PLATFOR_NATIVE */
     int fd;
     ssize_t readsize;
 #if NUM_CORES > 1
     unsigned my_core;
 #endif
-#endif /* !SIMULATOR */
+#endif /* CONFIG_PLATFORM */

 #if LCD_DEPTH > 1
     fb_data* old_backdrop;
@@ -755,7 +755,7 @@ int plugin_load(const char* plugin, const void* parameter)
     splash(0, ID2P(LANG_WAIT));
     strcpy(current_plugin, plugin);

-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
     hdr = sim_plugin_load((char *)plugin, &pd);
     if (pd == NULL) {
         splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
@@ -990,7 +990,7 @@ static int open_wrapper(const char* pathname, int flags, ...)
 /* we don't have an 'open' function. it's a define. and we need
  * the real file_open, hence PREFIX() doesn't work here */
     int fd;
-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
     if (flags & O_CREAT)
     {
         va_list ap;
diff --git a/apps/plugin.h b/apps/plugin.h
index a6b864b..709b93a 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -233,7 +233,7 @@ struct plugin_api {
     void (*lcd_yuv_set_options)(unsigned options);
 #endif
 #endif /* MEMORYSIZE > 2 */
-#elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
+#elif (LCD_DEPTH < 4) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
     void (*lcd_blit_mono)(const unsigned char *data, int x, int by, int width,
                           int bheight, int stride);
     void (*lcd_blit_grey_phase)(unsigned char *values, unsigned char *phases,
@@ -474,7 +474,7 @@ struct plugin_api {
 #endif

     void (*reset_poweroff_timer)(void);
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     int (*system_memory_guard)(int newmode);
     long *cpu_frequency;
 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
@@ -484,7 +484,7 @@ struct plugin_api {
     void (*cpu_boost)(bool on_off);
 #endif
 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */
 #ifdef HAVE_SCHEDULER_BOOSTCTRL
     void (*trigger_cpu_boost)(void);
     void (*cancel_cpu_boost)(void);
@@ -530,7 +530,7 @@ struct plugin_api {
     void (*remove_event)(unsigned short id, void (*handler)(void *data));
     void (*send_event)(unsigned short id, void *data);

-#ifdef SIMULATOR
+#ifdef (CONFIG_PLATFORM & PLATFORM_HOSTED)
     /* special simulator hooks */
 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
     void (*sim_lcd_ex_init)(unsigned long (*getpixel)(int, int));
@@ -553,7 +553,7 @@ struct plugin_api {
     void* (*memset)(void *dst, int c, size_t length);
     void* (*memcpy)(void *out, const void *in, size_t n);
     void* (*memmove)(void *out, const void *in, size_t n);
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     const unsigned char *_rbctype_;
 #endif
     int (*atoi)(const char *str);
@@ -584,7 +584,7 @@ struct plugin_api {
     int (*sound_enum_hw_eq_band_setting)(unsigned int band,
                                          unsigned int band_setting);
 #endif /* AUDIOHW_HAVE_EQ */
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     void (*mp3_play_data)(const unsigned char* start, int size,
                           void (*get_more)(unsigned char** start, size_t* size));
     void (*mp3_play_pause)(bool play);
@@ -593,7 +593,7 @@ struct plugin_api {
 #if CONFIG_CODEC != SWCODEC
     void (*bitswap)(unsigned char *data, int length);
 #endif
-#endif /* !SIMULATOR */
+#endif /* PLATFORM_NATIVE */
 #if CONFIG_CODEC == SWCODEC
     const unsigned long *audio_master_sampr_list;
     const unsigned long *hw_freq_sampr;
@@ -731,7 +731,7 @@ struct plugin_api {
     int (*battery_level)(void);
     bool (*battery_level_safe)(void);
     int (*battery_time)(void);
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     unsigned int (*battery_voltage)(void);
 #endif
 #if CONFIG_CHARGING
@@ -745,7 +745,7 @@ struct plugin_api {
 #endif

     /* misc */
-#if !defined(SIMULATOR)
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
     int* __errno;
 #endif
     void (*srand)(unsigned int seed);
@@ -902,7 +902,7 @@ struct plugin_header {
 };

 #ifdef PLUGIN
-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 extern unsigned char plugin_start_addr[];
 extern unsigned char plugin_end_addr[];
 #define PLUGIN_HEADER \
@@ -911,14 +911,14 @@ extern unsigned char plugin_end_addr[];
         __attribute__ ((section (".header")))= { \
         PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
         plugin_start_addr, plugin_end_addr, plugin_start, &rb };
-#else /* SIMULATOR */
+#else /* PLATFORM_HOSTED */
 #define PLUGIN_HEADER \
         const struct plugin_api *rb DATA_ATTR; \
         const struct plugin_header __header \
         __attribute__((visibility("default"))) = { \
         PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
         NULL, NULL, plugin_start, &rb };
-#endif /* SIMULATOR */
+#endif /* CONFIG_PLATFORM */

 #ifdef PLUGIN_USE_IRAM
 /* Declare IRAM variables */
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 401f5b9..2aa7c21 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -70,7 +70,7 @@ static unsigned long timestamp;
 #endif

 /* Crude work-around for Archos Sims - return a set amount */
-#if (CONFIG_CODEC != SWCODEC) && defined(SIMULATOR)
+#if (CONFIG_CODEC != SWCODEC) && (CONFIG_PLATFORM & PLATFORM_HOSTED)
 unsigned long audio_prev_elapsed(void)
 {
     return 120000;
diff --git a/apps/settings.c b/apps/settings.c
index 25593e5..d5b3627 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -835,7 +835,7 @@ void settings_apply(bool read_disk)
 #ifdef HAVE_DISK_STORAGE
     storage_spindown(global_settings.disk_spindown);
 #endif
-#if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR)
+#if (CONFIG_CODEC == MAS3507D) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
     dac_line_in(global_settings.line_in);
 #endif
     set_poweroff_timeout(global_settings.poweroff);
diff --git a/apps/status.h b/apps/status.h
index 36b723e..c8ec7bb 100644
--- a/apps/status.h
+++ b/apps/status.h
@@ -45,7 +45,7 @@ void status_set_ffmode(enum playmode mode);
 enum playmode status_get_ffmode(void);
 int current_playmode(void);

-#ifdef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
 #include <time.h>
 #endif
 #ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/tagcache.c b/apps/tagcache.c
index f4d3753..822a848 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -4442,7 +4442,7 @@ static void tagcache_thread(void)
             case SYS_POWEROFF:
                 break ;

-#ifndef SIMULATOR
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
             case SYS_USB_CONNECTED:
                 logf("USB: TagCache");
                 usb_acknowledge(SYS_USB_CONNECTED_ACK);
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 0ed1be4..8d15895 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -73,6 +73,13 @@
 #define AT91SAM9260  9260
 #define AS3525v2    35252

+/* platforms
+ * bit fields to allow PLATFORM_HOSTED to be OR'ed e.g. with a
+ * possible future PLATFORM_ANDROID (some OSes might need totally different
+ * handling to run on them than a stand-alone application) */
+#define PLATFORM_NATIVE (1<<0)
+#define PLATFORM_HOSTED (1<<1)
+
 /* CONFIG_KEYPAD */
 #define PLAYER_PAD          1
 #define RECORDER_PAD        2
@@ -496,6 +503,10 @@ Lyre prototype 1 */
 #define CONFIG_BACKLIGHT_FADING BACKLIGHT_NO_FADING
 #endif

+#ifndef CONFIG_PLATFORM
+#define CONFIG_PLATFORM PLATFORM_NATIVE
+#endif
+
 #ifndef CONFIG_TUNER
 #define CONFIG_TUNER 0
 #endif
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index d65b0fb..5dcb4f6 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -101,4 +101,5 @@

 #define HAVE_SDL
 #define HAVE_SDL_AUDIO
+#define CONFIG_PLATFORM PLATFORM_HOSTED
 #define _ISOC99_SOURCE 1