This repository has been archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <stdio.h> | ||
|
||
/* fp_force_eval ensures that the input value is computed when that's | ||
otherwise unused. To prevent the constant folding of the input | ||
expression, an additional fp_barrier may be needed or a compilation | ||
mode that does so (e.g. -frounding-math in gcc). Then it can be | ||
used to evaluate an expression for its fenv side-effects only. */ | ||
|
||
#ifndef fp_force_evalf | ||
#define fp_force_evalf fp_force_evalf | ||
static inline void fp_force_evalf(float x) | ||
{ | ||
volatile float y; | ||
y = x; | ||
} | ||
#endif | ||
|
||
#ifndef fp_force_eval | ||
#define fp_force_eval fp_force_eval | ||
static inline void fp_force_eval(double x) | ||
{ | ||
volatile double y; | ||
y = x; | ||
} | ||
#endif | ||
|
||
#ifndef fp_force_evall | ||
#define fp_force_evall fp_force_evall | ||
static inline void fp_force_evall(long double x) | ||
{ | ||
volatile long double y; | ||
y = x; | ||
} | ||
#endif | ||
|
||
#define FORCE_EVAL(x) do { \ | ||
if (sizeof(x) == sizeof(float)) { \ | ||
fp_force_evalf(x); \ | ||
} else if (sizeof(x) == sizeof(double)) { \ | ||
fp_force_eval(x); \ | ||
} else { \ | ||
fp_force_evall(x); \ | ||
} \ | ||
} while(0) | ||
|
||
void f() { | ||
FORCE_EVAL(0/0.0f); | ||
} | ||
|
||
volatile double x = -1; | ||
|
||
int main() { | ||
printf("%f, %f\n", 0/0.0, x/0.0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"unsafe" | ||
) | ||
|
||
func gostring(s *int8) string { | ||
n, arr := 0, (*[1 << 20]byte)(unsafe.Pointer(s)) | ||
for arr[n] != 0 { | ||
n++ | ||
} | ||
return string(arr[:n]) | ||
} | ||
|
||
func printf(format *int8, args ...interface{}) int32 { | ||
goformat := gostring(format) | ||
for i, arg := range args { | ||
if v, ok := arg.(*int8); ok { | ||
args[i] = gostring(v) | ||
} | ||
} | ||
s := strings.ToLower(fmt.Sprintf(goformat, args...)) | ||
fmt.Print(s) | ||
return 0 | ||
} | ||
|
||
func __swbuf(_c int32, _p *FILE) int32 { | ||
return _c | ||
} | ||
|
||
type struct___sFILEX struct{} | ||
|
||
type struct__IO_marker struct{} | ||
type struct__IO_codecvt struct{} | ||
type struct__IO_wide_data struct{} |