chore:keep origin c format

This commit is contained in:
luoliwoshang
2025-06-11 20:30:44 +08:00
parent efabdf27c8
commit 4f5c95045d
7 changed files with 41 additions and 26 deletions

View File

@@ -490,8 +490,6 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, conf *Co
}
linkArgs = append(linkArgs, exargs...)
fmt.Fprintf(os.Stderr, "linkArgs: %v\n", linkArgs)
err = compileAndLinkLLFiles(ctx, app, llFiles, linkArgs, verbose)
check(err)

View File

@@ -1,33 +1,39 @@
typedef union {
typedef union
{
double d;
float f;
long v;
long long ll;
} castUnion;
extern "C" {
extern "C" {
double llgoToFloat64(long long v) {
double llgoToFloat64(long long v)
{
castUnion k;
k.ll = v;
return k.d;
}
float llgoToFloat32(int v) {
float llgoToFloat32(int v)
{
castUnion k;
k.v = v;
return k.f;
}
long long llgoFromFloat64(double v) {
long long llgoFromFloat64(double v)
{
castUnion k;
k.d = v;
return k.ll;
}
int llgoFromFloat32(float v) {
int llgoFromFloat32(float v)
{
castUnion k;
k.f = v;
return k.v;
}
}
}

View File

@@ -11,9 +11,13 @@
extern "C" {
void *llgo_address() { return __builtin_return_address(0); }
void *llgo_address() {
return __builtin_return_address(0);
}
int llgo_addrinfo(void *addr, Dl_info *info) { return dladdr(addr, info); }
int llgo_addrinfo(void *addr, Dl_info *info) {
return dladdr(addr, info);
}
void llgo_stacktrace(int skip, void *ctx, int (*fn)(void *ctx, void *pc, void *offset, void *sp, char *name)) {
unw_cursor_t cursor;
@@ -31,10 +35,11 @@ void llgo_stacktrace(int skip, void *ctx, int (*fn)(void *ctx, void *pc, void *o
if (unw_get_reg(&cursor, UNW_REG_IP, &pc) == 0) {
unw_get_proc_name(&cursor, fname, sizeof(fname), &offset);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
if (fn(ctx, (void *)pc, (void *)offset, (void *)sp, fname) == 0) {
if (fn(ctx, (void*)pc, (void*)offset, (void*)sp, fname) == 0) {
return;
}
}
}
}
}

View File

@@ -1,15 +1,18 @@
#include <errno.h>
#include <stdlib.h>
#include <errno.h>
extern "C" {
int cliteClearenv() {
extern char **environ;
if (environ != NULL) {
*environ = NULL;
}
return 0;
int cliteClearenv()
{
extern char **environ;
if (environ != NULL)
{
*environ = NULL;
}
return 0;
}
int cliteErrno() { return errno; }
}
}

View File

@@ -9,6 +9,8 @@ struct fcntl_ret
int32_t err; // Error code
};
extern "C" {
// llgo_fcntl implements the fcntl system call wrapper for Go
// fd: file descriptor
// cmd: fcntl command
@@ -30,4 +32,6 @@ struct fcntl_ret llgo_fcntl2(int32_t fd, int32_t cmd, int32_t arg)
}
return ret;
}
}
}

View File

@@ -2,11 +2,13 @@
extern "C" {
int llgo_maxprocs() {
int llgo_maxprocs()
{
#ifdef _SC_NPROCESSORS_ONLN
return (int)sysconf(_SC_NPROCESSORS_ONLN);
#else
return 1;
#endif
}
}
}

View File

@@ -91,7 +91,6 @@ func (p *Cmd) execWithFlags(flags []string, args ...string) error {
if p.Env != nil {
cmd.Env = p.Env
}
fmt.Fprintln(os.Stderr, cmd.String())
return cmd.Run()
}
@@ -132,8 +131,6 @@ func (p *Cmd) CheckLinkArgs(cmdArgs []string, wasm bool) error {
srcIn := strings.NewReader(src)
p.Stdin = srcIn
fmt.Fprintf(os.Stderr, "args: %v\n", args)
// Execute the command
return p.execWithFlags([]string{"LDFLAGS", "CCFLAGS"}, args...)
}