summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-opt-report/Inputs/sr2.c
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/tools/llvm-opt-report/Inputs/sr2.c')
-rw-r--r--llvm/test/tools/llvm-opt-report/Inputs/sr2.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-opt-report/Inputs/sr2.c b/llvm/test/tools/llvm-opt-report/Inputs/sr2.c
new file mode 100644
index 00000000000..79ee519e67f
--- /dev/null
+++ b/llvm/test/tools/llvm-opt-report/Inputs/sr2.c
@@ -0,0 +1,35 @@
+/*
+** Write a 64-bit variable-length integer to memory starting at p[0].
+** The length of data write will be between 1 and 9 bytes. The number
+** of bytes written is returned.
+**
+** A variable-length integer consists of the lower 7 bits of each byte
+** for all bytes that have the 8th bit set and one byte with the 8th
+** bit clear. Except, if we get to the 9th byte, it stores the full
+** 8 bits and is the last byte.
+*/
+SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){
+ int i, j, n;
+ u8 buf[10];
+ if( v & (((u64)0xff000000)<<32) ){
+ p[8] = v;
+ v >>= 8;
+ for(i=7; i>=0; i--){
+ p[i] = (v & 0x7f) | 0x80;
+ v >>= 7;
+ }
+ return 9;
+ }
+ n = 0;
+ do{
+ buf[n++] = (v & 0x7f) | 0x80;
+ v >>= 7;
+ }while( v!=0 );
+ buf[0] &= 0x7f;
+ assert( n<=9 );
+ for(i=0, j=n-1; j>=0; j--, i++){
+ p[i] = buf[j];
+ }
+ return n;
+}
+
OpenPOWER on IntegriCloud