Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

OpenLibm working on 16-bit 8086

Aperta
#259 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c

Direzione di ricerca

Esamina src/fpmath.h, src/i386_fpmath.h e src/math_private.h insieme al contesto fornito di ELKS e ia16-elf-gcc. Verifica le assunzioni esistenti sulle larghezze degli interi e sui bitfield, quindi compila o testa la libreria per il target a 16 bit. Il lavoro è completato quando il problema di portabilità è risolto senza compromettere i layout esistenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello all,

I'm not sure whether anyone is interested in this, but I have successfully ported a number of the OpenLibm math routines to ELKS, an 8086-based Linux kernel and C library, using the ia16-elf-gcc compiler. In this system, int is 16 bits, and long 32 bits. float and double are IEEE 754 32 and 64 bits.

The following patch was required. It may (or may not) be a good idea to consider changing the non-portable unsigned int definitions to something like uint32_t for portability. Not knowing this library well, I am unsure whether unsigned int may need to be 64 bits on some systems, in which case, this would not work. However, it seems the IEEEf2bits structure assumes unsigned int to be 32 bits for its bitfield definitions.

diff --git a/src/fpmath.h b/src/fpmath.h
index 6c37595..5843386 100644
--- a/src/fpmath.h
+++ b/src/fpmath.h
@@ -83,13 +83,13 @@ union IEEEf2bits {
        float   f;
        struct {
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-               unsigned int    man     :23;
-               unsigned int    exp     :8;
-               unsigned int    sign    :1;
+               unsigned long   man     :23;
+               unsigned long   exp     :8;
+               unsigned long   sign    :1;
 #else /* _BIG_ENDIAN */
-               unsigned int    sign    :1;
-               unsigned int    exp     :8;
-               unsigned int    man     :23;
+               unsigned long   sign    :1;
+               unsigned long   exp     :8;
+               unsigned long   man     :23;
 #endif
        } bits;
 };
@@ -102,19 +102,19 @@ union IEEEd2bits {
        struct {
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
-               unsigned int    manl    :32;
+               unsigned long   manl    :32;
 #endif
-               unsigned int    manh    :20;
-               unsigned int    exp     :11;
-               unsigned int    sign    :1;
+               unsigned long   manh    :20;
+               unsigned long   exp     :11;
+               unsigned long   sign    :1;
 #if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
-               unsigned int    manl    :32;
+               unsigned long   manl    :32;
 #endif
 #else /* _BIG_ENDIAN */
-               unsigned int    sign    :1;
-               unsigned int    exp     :11;
-               unsigned int    manh    :20;
-               unsigned int    manl    :32;
+               unsigned long   sign    :1;
+               unsigned long   exp     :11;
+               unsigned long   manh    :20;
+               unsigned long   manl    :32;
 #endif
        } bits;
 };
diff --git a/src/i386_fpmath.h b/src/i386_fpmath.h
index 455631c..8b29e38 100644
--- a/src/i386_fpmath.h
+++ b/src/i386_fpmath.h
@@ -29,16 +29,16 @@
 union IEEEl2bits {
        long double     e;
        struct {
-               unsigned int    manl    :32;
-               unsigned int    manh    :32;
-               unsigned int    exp     :15;
-               unsigned int    sign    :1;
-               unsigned int    junk    :16;
+               unsigned long   manl    :32;
+               unsigned long   manh    :32;
+               unsigned long   exp     :15;
+               unsigned long   sign    :1;
+               unsigned long   junk    :16;
        } bits;
        struct {
                unsigned long long man  :64;
-               unsigned int    expsign :16;
-               unsigned int    junk    :16;
+               unsigned long   expsign :16;
+               unsigned long   junk    :16;
        } xbits;
 };
 
diff --git a/src/math_private.h b/src/math_private.h
index 15a27b2..4f7e1d4 100644
--- a/src/math_private.h
+++ b/src/math_private.h
@@ -162,7 +162,7 @@ typedef union
 {
   float value;
   /* FIXME: Assumes 32 bit int.  */
-  unsigned int word;
+  unsigned long word;
 } ieee_float_shape_type;
 
 /* Get a 32 bit int from a float.  */

Thank you!

Lingua principale
C
Stelle
632
Fork
163
Merge medio
4m
PR unite (30g)
1

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaMath/openlibm

Tutte le issue di JuliaMath/openlibm

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.