PatchworkOS
Loading...
Searching...
No Matches
print.c File Reference
#include "print.h"
#include "common/digits.h"
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "user/common/file.h"

Go to the source code of this file.

Macros

#define _DBL_SIGN(bytes)   (((unsigned)bytes[7] & 0x80) >> 7)
 
#define _DBL_DEC(bytes)   ((_DBL_EXP(bytes) > 0) ? 1 : 0)
 
#define _DBL_EXP(bytes)   ((((unsigned)bytes[7] & 0x7f) << 4) | (((unsigned)bytes[6] & 0xf0) >> 4))
 
#define _DBL_BIAS   1023
 
#define _DBL_MANT_START(bytes)   (bytes + 6)
 
#define _LDBL_SIGN(bytes)   (((unsigned)bytes[7] & 0x80) >> 7)
 
#define _LDBL_DEC(bytes)   ((_LDBL_EXP(bytes) > 0) ? 1 : 0)
 
#define _LDBL_EXP(bytes)   ((((unsigned)bytes[7] & 0x7f) << 4) | (((unsigned)bytes[6] & 0xf0) >> 4))
 
#define _LDBL_BIAS   1023
 
#define _LDBL_MANT_START(bytes)   (bytes + 6)
 
#define _PRINT_PUT(ctx, x)
 

Functions

static void _print_hexa (int sign, int exp, int dec, unsigned char const *mant, size_t mant_dig, _format_ctx_t *ctx)
 
static void _print_fp (int sign, int exp, int dec, unsigned char const *mant, size_t mant_dig, _format_ctx_t *ctx)
 
static void _print_double (double value, _format_ctx_t *ctx)
 
static void _print_ldouble (long double value, _format_ctx_t *ctx)
 
static void _int_format (intmax_t value, _format_ctx_t *ctx)
 
static void _print_integer (imaxdiv_t div, _format_ctx_t *ctx)
 
static void _print_string (const char *s, _format_ctx_t *ctx)
 
const char * _print (const char *spec, _format_ctx_t *ctx)
 

Macro Definition Documentation

◆ _DBL_BIAS

#define _DBL_BIAS   1023

Definition at line 21 of file print.c.

◆ _DBL_DEC

#define _DBL_DEC (   bytes)    ((_DBL_EXP(bytes) > 0) ? 1 : 0)

Definition at line 19 of file print.c.

◆ _DBL_EXP

#define _DBL_EXP (   bytes)    ((((unsigned)bytes[7] & 0x7f) << 4) | (((unsigned)bytes[6] & 0xf0) >> 4))

Definition at line 20 of file print.c.

◆ _DBL_MANT_START

#define _DBL_MANT_START (   bytes)    (bytes + 6)

Definition at line 22 of file print.c.

◆ _DBL_SIGN

#define _DBL_SIGN (   bytes)    (((unsigned)bytes[7] & 0x80) >> 7)

Definition at line 18 of file print.c.

◆ _LDBL_BIAS

#define _LDBL_BIAS   1023

Definition at line 48 of file print.c.

◆ _LDBL_DEC

#define _LDBL_DEC (   bytes)    ((_LDBL_EXP(bytes) > 0) ? 1 : 0)

Definition at line 46 of file print.c.

◆ _LDBL_EXP

#define _LDBL_EXP (   bytes)    ((((unsigned)bytes[7] & 0x7f) << 4) | (((unsigned)bytes[6] & 0xf0) >> 4))

Definition at line 47 of file print.c.

◆ _LDBL_MANT_START

#define _LDBL_MANT_START (   bytes)    (bytes + 6)

Definition at line 49 of file print.c.

◆ _LDBL_SIGN

#define _LDBL_SIGN (   bytes)    (((unsigned)bytes[7] & 0x80) >> 7)

Definition at line 45 of file print.c.

◆ _PRINT_PUT

#define _PRINT_PUT (   ctx,
  x 
)
Value:
({ \
int character = x; \
if ((ctx)->totalChars < (ctx)->maxChars) \
{ \
if ((ctx)->stream != NULL) \
{ \
putc(character, (ctx)->stream); \
} \
else \
{ \
(ctx)->buffer[(ctx)->totalChars] = character; \
} \
} \
++((ctx)->totalChars); \
})
#define NULL
Pointer error value.
Definition NULL.h:23
EFI_PHYSICAL_ADDRESS buffer
Definition mem.c:15
int64_t x
Definition main.c:152

Definition at line 53 of file print.c.

Function Documentation

◆ _int_format()

◆ _print()

◆ _print_double()

static void _print_double ( double  value,
_format_ctx_t ctx 
)
static

Definition at line 333 of file print.c.

References _DBL_BIAS, _DBL_DEC, _DBL_EXP, _DBL_MANT_START, _DBL_SIGN, _print_fp(), exp(), INT_MAX, INT_MIN, and memcpy().

Referenced by _print().

◆ _print_fp()

static void _print_fp ( int  sign,
int  exp,
int  dec,
unsigned char const *  mant,
size_t  mant_dig,
_format_ctx_t ctx 
)
static

◆ _print_hexa()

static void _print_hexa ( int  sign,
int  exp,
int  dec,
unsigned char const *  mant,
size_t  mant_dig,
_format_ctx_t ctx 
)
static

◆ _print_integer()

◆ _print_ldouble()

static void _print_ldouble ( long double  value,
_format_ctx_t ctx 
)
static

Definition at line 349 of file print.c.

References _LDBL_BIAS, _LDBL_DEC, _LDBL_EXP, _LDBL_MANT_START, _LDBL_SIGN, _print_fp(), exp(), INT_MAX, INT_MIN, and memcpy().

Referenced by _print().

◆ _print_string()

static void _print_string ( const char *  s,
_format_ctx_t ctx 
)
static