{"thread":{"id":"306","subject":"[PATCH GIT 0.6] make use of register variables & size_t","startedAt":"2005-04-25T11:18:09Z","lastAt":"2005-04-25T20:50:09Z","messageCount":21,"participants":["Matthias-Christian Ott","Rene Rebe","Petr Baudis","Pekka Enberg","Linus Torvalds","Jan-Benedict Glaw","Thomas Glanzmann","valdis.kletnieks@vt.edu","Dmitry Torokhov","David A. Wheeler","Brian O'Mahoney","Arjan van de Ven"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1604","messageId":"426CD1F1.2010101@tiscali.de","threadId":"306","inReplyTo":null,"subject":"[PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T11:18:09Z","receivedAt":"2005-04-25T11:18:09Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"The \"git\" didn't try store small variables, which aren't referenced, in \nthe processor registers. It also didn't use the size_t type. I corrected \na C++ style comment too.\n\nSigned-off-by: Matthias-Christian Ott <matthias.christian@tiscali.de>\n\n--\n\ndiff -Npru git-0.6/check-files.c git-0.6-ott/check-files.c\n--- git-0.6/check-files.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/check-files.c\t2005-04-24 17:27:17.000000000 +0200\n@@ -38,7 +38,7 @@ static void check_file(const char *path)\n\n  int main(int argc, char **argv)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \tread_cache();\n  \tfor (i = 1; i < argc ; i++)\ndiff -Npru git-0.6/checkout-cache.c git-0.6-ott/checkout-cache.c\n--- git-0.6/checkout-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/checkout-cache.c\t2005-04-24 17:29:59.000000000 +0200\n@@ -52,7 +52,7 @@ static void create_directories(const cha\n\n  static int create_file(const char *path, unsigned int mode)\n  {\n-\tint fd;\n+\tregister int fd;\n\n  \tmode = (mode & 0100) ? 0777 : 0666;\n  \tfd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);\n@@ -67,10 +67,10 @@ static int create_file(const char *path,\n\n  static int write_entry(struct cache_entry *ce, const char *path)\n  {\n-\tint fd;\n+\tregister int fd;\n  \tvoid *new;\n  \tunsigned long size;\n-\tlong wrote;\n+\tregister long wrote;\n  \tchar type[20];\n\n  \tnew = read_sha1_file(ce->sha1, type, &size);\n@@ -142,7 +142,7 @@ static int checkout_file(const char *nam\n\n  static int checkout_all(const char *base_dir)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \tfor (i = 0; i < active_nr ; i++) {\n  \t\tstruct cache_entry *ce = active_cache[i];\n@@ -156,7 +156,8 @@ static int checkout_all(const char *base\n\n  int main(int argc, char **argv)\n  {\n-\tint i, force_filename = 0;\n+\tregister unsigned int i;\n+\tregister int force_filename = 0;\n  \tconst char *base_dir = \"\";\n\n  \tif (read_cache() < 0) {\ndiff -Npru git-0.6/commit.c git-0.6-ott/commit.c\n--- git-0.6/commit.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/commit.c\t2005-04-24 17:30:31.000000000 +0200\n@@ -23,7 +23,7 @@ struct commit *lookup_commit(unsigned ch\n\n  static unsigned long parse_commit_date(const char *buf)\n  {\n-\tunsigned long date;\n+\tregister unsigned long date;\n\n  \tif (memcmp(buf, \"author\", 6))\n  \t\treturn 0;\ndiff -Npru git-0.6/commit-tree.c git-0.6-ott/commit-tree.c\n--- git-0.6/commit-tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/commit-tree.c\t2005-04-24 19:57:37.000000000 +0200\n@@ -5,6 +5,7 @@\n   */\n  #include \"cache.h\"\n\n+#include <stddef.h>\n  #include <pwd.h>\n  #include <time.h>\n  #include <string.h>\n@@ -32,7 +33,7 @@ static void add_buffer(char **bufp, unsi\n  {\n  \tchar one_line[2048];\n  \tva_list args;\n-\tint len;\n+\tregister int len;\n  \tunsigned long alloc, size, newsize;\n  \tchar *buf;\n\n@@ -64,8 +65,8 @@ static int prepend_integer(char *buffer,\n\n  static void finish_buffer(char *tag, char **bufp, unsigned int *sizep)\n  {\n-\tint taglen;\n-\tint offset;\n+\tsize_t taglen;\n+\tregister int offset;\n  \tchar *buf = *bufp;\n  \tunsigned int size = *sizep;\n\n@@ -82,7 +83,7 @@ static void finish_buffer(char *tag, cha\n\n  static void remove_special(char *p)\n  {\n-\tchar c;\n+\tregister char c;\n  \tchar *dst = p, *src = p;\n\n  \tfor (;;) {\n@@ -137,7 +138,8 @@ static void parse_rfc2822_date(char *dat\n  {\n  \tstruct tm tm;\n  \tchar *p;\n-\tint i, offset;\n+\tregister unsigned short int i;\n+\tregister int offset;\n  \ttime_t then;\n\n  \tmemset(&tm, 0, sizeof(tm));\n@@ -277,8 +279,9 @@ static char *commit_tree_usage = \"commit\n\n  int main(int argc, char **argv)\n  {\n-\tint i, len;\n-\tint parents = 0;\n+\tregister int i;\n+\tregister size_t len;\n+\tregister unsigned int parents = 0;\n  \tunsigned char tree_sha1[20];\n  \tunsigned char parent_sha1[MAXPARENT][20];\n  \tunsigned char commit_sha1[20];\ndiff -Npru git-0.6/convert-cache.c git-0.6-ott/convert-cache.c\n--- git-0.6/convert-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/convert-cache.c\t2005-04-24 17:42:09.000000000 +0200\n@@ -1,5 +1,7 @@\n  #include \"cache.h\"\n\n+#include <stddef.h>\n+\n  struct entry {\n  \tunsigned char old_sha1[20];\n  \tunsigned char new_sha1[20];\n@@ -29,7 +31,8 @@ static struct entry *insert_new(unsigned\n\n  static struct entry *lookup_entry(unsigned char *sha1)\n  {\n-\tint low = 0, high = nr_convert;\n+\tregister unsigned int low = 0;\n+\tregister int high = nr_convert;\n\n  \twhile (low < high) {\n  \t\tint next = (low + high) / 2;\n@@ -70,8 +73,10 @@ static void convert_ascii_sha1(void *buf\n\n  static void convert_tree(void *buffer, unsigned long size)\n  {\n+\tregister size_t len;\n+\t\n  \twhile (size) {\n-\t\tint len = 1+strlen(buffer);\n+\t\tlen = 1+strlen(buffer);\n\n  \t\tconvert_binary_sha1(buffer + len);\n\n@@ -98,7 +103,8 @@ static struct entry * convert_entry(unsi\n  \tstruct entry *entry = lookup_entry(sha1);\n  \tchar type[20];\n  \tvoid *buffer, *data;\n-\tunsigned long size, offset;\n+\tunsigned long size;\n+\tregister unsigned long offset;\n\n  \tif (entry->converted)\n  \t\treturn entry;\ndiff -Npru git-0.6/diff-cache.c git-0.6-ott/diff-cache.c\n--- git-0.6/diff-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/diff-cache.c\t2005-04-24 19:59:51.000000000 +0200\n@@ -1,5 +1,7 @@\n  #include \"cache.h\"\n\n+#include <stddef.h>\n+\n  static int cached_only = 0;\n  static int recursive = 0;\n  static int line_termination = '\\n';\n@@ -9,8 +11,8 @@ static int diff_cache(void *tree, unsign\n  static void update_tree_entry(void **bufp, unsigned long *sizep)\n  {\n  \tvoid *buf = *bufp;\n-\tunsigned long size = *sizep;\n-\tint len = strlen(buf) + 1 + 20;\n+\tregister unsigned long size = *sizep;\n+\tregister size_t len = strlen(buf) + 1 + 20;\n\n  \tif (size < len)\n  \t\tdie(\"corrupt tree file 1 (%s)\", size);\n@@ -20,7 +22,7 @@ static void update_tree_entry(void **buf\n\n  static const unsigned char *extract(void *tree, unsigned long size, \nconst char **pathp, unsigned int *modep)\n  {\n-\tint len = strlen(tree)+1;\n+\tregister size_t len = strlen(tree)+1;\n  \tconst unsigned char *sha1 = tree + len;\n  \tconst char *path = strchr(tree, ' ');\n\n@@ -84,10 +86,10 @@ static void show_file(const char *prefix\n  static int compare_tree_entry(const char *path1, unsigned int mode1, \nconst unsigned char *sha1,\n  \t\t\t      struct cache_entry **ac, int *entries, const char *base)\n  {\n-\tint baselen = strlen(base);\n+\tregister size_t baselen = strlen(base);\n  \tstruct cache_entry *ce = *ac;\n  \tconst char *path2 = ce->name + baselen;\n-\tunsigned int mode2 = ntohl(ce->ce_mode);\n+\tregister unsigned int mode2 = ntohl(ce->ce_mode);\n  \tconst unsigned char *sha2 = ce->sha1;\n  \tint cmp, pathlen1, pathlen2;\n  \tchar old_sha1_hex[50];\n@@ -160,7 +162,7 @@ static int compare_tree_entry(const char\n\n  static int diff_cache(void *tree, unsigned long size, struct \ncache_entry **ac, int entries, const char *base)\n  {\n-\tint baselen = strlen(base);\n+\tregister size_t baselen = strlen(base);\n\n  \tfor (;;) {\n  \t\tstruct cache_entry *ce;\ndiff -Npru git-0.6/diff-tree.c git-0.6-ott/diff-tree.c\n--- git-0.6/diff-tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/diff-tree.c\t2005-04-24 17:48:24.000000000 +0200\n@@ -1,5 +1,7 @@\n  #include \"cache.h\"\n\n+#include <stddef.h>\n+\n  static int recursive = 0;\n  static int line_termination = '\\n';\n\n@@ -8,8 +10,8 @@ static int diff_tree_sha1(const unsigned\n  static void update_tree_entry(void **bufp, unsigned long *sizep)\n  {\n  \tvoid *buf = *bufp;\n-\tunsigned long size = *sizep;\n-\tint len = strlen(buf) + 1 + 20;\n+\tregister unsigned long size = *sizep;\n+\tregister size_t len = strlen(buf) + 1 + 20;\n\n  \tif (size < len)\n  \t\tdie(\"corrupt tree file\");\n@@ -19,7 +21,7 @@ static void update_tree_entry(void **buf\n\n  static const unsigned char *extract(void *tree, unsigned long size, \nconst char **pathp, unsigned int *modep)\n  {\n-\tint len = strlen(tree)+1;\n+\tregister size_t len = strlen(tree)+1;\n  \tconst unsigned char *sha1 = tree + len;\n  \tconst char *path = strchr(tree, ' ');\n\n@@ -31,7 +33,7 @@ static const unsigned char *extract(void\n\n  static char *malloc_base(const char *base, const char *path, int pathlen)\n  {\n-\tint baselen = strlen(base);\n+\tregister size_t baselen = strlen(base);\n  \tchar *newbase = malloc(baselen + pathlen + 2);\n  \tmemcpy(newbase, base, baselen);\n  \tmemcpy(newbase + baselen, path, pathlen);\n@@ -85,7 +87,8 @@ static int compare_tree_entry(void *tree\n  \tunsigned mode1, mode2;\n  \tconst char *path1, *path2;\n  \tconst unsigned char *sha1, *sha2;\n-\tint cmp, pathlen1, pathlen2;\n+\tregister int cmp;\n+\tregister size_t pathlen1, pathlen2;\n  \tchar old_sha1_hex[50];\n\n  \tsha1 = extract(tree1, size1, &path1, &mode1);\ndiff -Npru git-0.6/fsck-cache.c git-0.6-ott/fsck-cache.c\n--- git-0.6/fsck-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/fsck-cache.c\t2005-04-24 17:50:15.000000000 +0200\n@@ -14,7 +14,7 @@ static unsigned char head_sha1[20];\n\n  static void check_connectivity(void)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \t/* Look up all the requirements, warn about missing objects.. */\n  \tfor (i = 0; i < nr_objs; i++) {\n@@ -133,7 +133,7 @@ static int fsck_dir(int i, char *path)\n\n  int main(int argc, char **argv)\n  {\n-\tint i, heads;\n+\tregister unsigned int i, heads;\n  \tchar *sha1_dir;\n\n  \tsha1_dir = getenv(DB_ENVIRONMENT) ? : DEFAULT_DB_ENVIRONMENT;\ndiff -Npru git-0.6/init-db.c git-0.6-ott/init-db.c\n--- git-0.6/init-db.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/init-db.c\t2005-04-24 19:53:49.000000000 +0200\n@@ -24,7 +24,8 @@ void safe_create_dir(char *dir)\n  int main(int argc, char **argv)\n  {\n  \tchar *sha1_dir, *path;\n-\tint len, i;\n+\tregister size_t len;\n+\tregister unsigned short int i;\n\n  \tsafe_create_dir(\".git\");\n\ndiff -Npru git-0.6/merge-cache.c git-0.6-ott/merge-cache.c\n--- git-0.6/merge-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/merge-cache.c\t2005-04-24 19:59:07.000000000 +0200\n@@ -8,7 +8,8 @@ static const char *arguments[5];\n\n  static void run_program(void)\n  {\n-\tint pid = fork(), status;\n+\tregister int pid = fork();\n+\tint status;\n\n  \tif (pid < 0)\n  \t\tdie(\"unable to fork\");\n@@ -27,7 +28,7 @@ static void run_program(void)\n\n  static int merge_entry(int pos, const char *path)\n  {\n-\tint found;\n+\tregister unsigned int found;\n  \t\n  \tif (pos >= active_nr)\n  \t\tdie(\"merge-cache: %s not in the cache\", path);\n@@ -56,7 +57,7 @@ static int merge_entry(int pos, const ch\n\n  static void merge_file(const char *path)\n  {\n-\tint pos = cache_name_pos(path, strlen(path));\n+\tregister int pos = cache_name_pos(path, strlen(path));\n\n  \t/*\n  \t * If it already exists in the cache as stage0, it's\n@@ -68,7 +69,7 @@ static void merge_file(const char *path)\n\n  static void merge_all(void)\n  {\n-\tint i;\n+\tregister unsigned int i;\n  \tfor (i = 0; i < active_nr; i++) {\n  \t\tstruct cache_entry *ce = active_cache[i];\n  \t\tif (!ce_stage(ce))\n@@ -79,7 +80,7 @@ static void merge_all(void)\n\n  int main(int argc, char **argv)\n  {\n-\tint i, force_file = 0;\n+\tregister unsigned short int i, force_file = 0;\n\n  \tif (argc < 3)\n  \t\tusage(\"merge-cache <merge-program> (-a | <filename>*)\");\ndiff -Npru git-0.6/object.c git-0.6-ott/object.c\n--- git-0.6/object.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/object.c\t2005-04-24 19:51:16.000000000 +0200\n@@ -9,7 +9,8 @@ static int obj_allocs;\n\n  static int find_object(unsigned char *sha1)\n  {\n-\tint first = 0, last = nr_objs;\n+\tregister int first = 0;\n+\tregister int last = nr_objs;\n\n          while (first < last) {\n                  int next = (first + last) / 2;\ndiff -Npru git-0.6/read-cache.c git-0.6-ott/read-cache.c\n--- git-0.6/read-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/read-cache.c\t2005-04-24 20:53:51.000000000 +0200\n@@ -3,6 +3,7 @@\n   *\n   * Copyright (C) Linus Torvalds, 2005\n   */\n+#include <stddef.h>\n  #include <stdarg.h>\n  #include \"cache.h\"\n\n@@ -11,7 +12,7 @@ unsigned int active_nr = 0, active_alloc\n\n  int cache_match_stat(struct cache_entry *ce, struct stat *st)\n  {\n-\tunsigned int changed = 0;\n+\tregister unsigned int changed = 0;\n\n  \tif (ce->ce_mtime.sec != htonl(st->st_mtime))\n  \t\tchanged |= MTIME_CHANGED;\n@@ -46,10 +47,10 @@ int cache_match_stat(struct cache_entry\n\n  int cache_name_compare(const char *name1, int flags1, const char \n*name2, int flags2)\n  {\n-\tint len1 = flags1 & CE_NAMEMASK;\n-\tint len2 = flags2 & CE_NAMEMASK;\n-\tint len = len1 < len2 ? len1 : len2;\n-\tint cmp;\n+\tregister int len1 = flags1 & CE_NAMEMASK;\n+\tregister int len2 = flags2 & CE_NAMEMASK;\n+\tregister int len = len1 < len2 ? len1 : len2;\n+\tregister int cmp;\n\n  \tcmp = memcmp(name1, name2, len);\n  \tif (cmp)\n@@ -67,7 +68,7 @@ int cache_name_compare(const char *name1\n\n  int cache_name_pos(const char *name, int namelen)\n  {\n-\tint first, last;\n+\tregister unsigned int first, last;\n\n  \tfirst = 0;\n  \tlast = active_nr;\n@@ -98,7 +99,7 @@ static int remove_entry_at(int pos)\n\n  int remove_file_from_cache(char *path)\n  {\n-\tint pos = cache_name_pos(path, strlen(path));\n+\tregister int pos = cache_name_pos(path, strlen(path));\n  \tif (pos < 0)\n  \t\tpos = -pos-1;\n  \twhile (pos < active_nr && !strcmp(active_cache[pos]->name, path))\n@@ -108,13 +109,13 @@ int remove_file_from_cache(char *path)\n\n  static int same_name(struct cache_entry *a, struct cache_entry *b)\n  {\n-\tint len = ce_namelen(a);\n+\tregister int len = ce_namelen(a);\n  \treturn ce_namelen(b) == len && !memcmp(a->name, b->name, len);\n  }\n\n  int add_cache_entry(struct cache_entry *ce, int ok_to_add)\n  {\n-\tint pos;\n+\tregister int pos;\n\n  \tpos = cache_name_pos(ce->name, htons(ce->ce_flags));\n\n@@ -173,9 +174,11 @@ static int verify_hdr(struct cache_heade\n\n  int read_cache(void)\n  {\n-\tint fd, i;\n+\tregister int fd;\n+\tregister unsigned int i;\n  \tstruct stat st;\n-\tunsigned long size, offset;\n+\tregister unsigned long size;\n+\tregister size_t offset;\n  \tvoid *map;\n  \tstruct cache_header *hdr;\n\n@@ -192,7 +195,7 @@ int read_cache(void)\n  \tif (fd < 0)\n  \t\treturn (errno == ENOENT) ? 0 : error(\"open failed\");\n\n-\tsize = 0; // avoid gcc warning\n+\tsize = 0; /* avoid gcc warning */\n  \tmap = (void *)-1;\n  \tif (!fstat(fd, &st)) {\n  \t\tsize = st.st_size;\n@@ -254,7 +257,7 @@ static int ce_write(SHA_CTX *context, in\n\n  static int ce_flush(SHA_CTX *context, int fd)\n  {\n-\tunsigned int left = write_buffer_len;\n+\tregister unsigned int left = write_buffer_len;\n\n  \tif (left) {\n  \t\twrite_buffer_len = 0;\n@@ -273,7 +276,7 @@ int write_cache(int newfd, struct cache_\n  {\n  \tSHA_CTX c;\n  \tstruct cache_header hdr;\n-\tint i;\n+\tregister unsigned int i;\n\n  \thdr.hdr_signature = htonl(CACHE_SIGNATURE);\n  \thdr.hdr_version = htonl(2);\ndiff -Npru git-0.6/read-tree.c git-0.6-ott/read-tree.c\n--- git-0.6/read-tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/read-tree.c\t2005-04-24 19:57:05.000000000 +0200\n@@ -9,8 +9,8 @@ static int stage = 0;\n\n  static int read_one_entry(unsigned char *sha1, const char *base, int \nbaselen, const char *pathname, unsigned mode)\n  {\n-\tint len = strlen(pathname);\n-\tunsigned int size = cache_entry_size(baselen + len);\n+\tregister size_t len = strlen(pathname);\n+\tregister unsigned int size = cache_entry_size(baselen + len);\n  \tstruct cache_entry *ce = malloc(size);\n\n  \tmemset(ce, 0, size);\n@@ -29,8 +29,10 @@ static int read_tree_recursive(void *buf\n  {\n  \tif (!buffer || strcmp(type, \"tree\"))\n  \t\treturn -1;\n+\tregister size_t len;\n+\t\n  \twhile (size) {\n-\t\tint len = strlen(buffer)+1;\n+\t\tlen = strlen(buffer)+1;\n  \t\tunsigned char *sha1 = buffer + len;\n  \t\tchar *path = strchr(buffer, ' ')+1;\n  \t\tunsigned int mode;\n@@ -89,7 +91,7 @@ static void remove_lock_file(void)\n\n  static int path_matches(struct cache_entry *a, struct cache_entry *b)\n  {\n-\tint len = ce_namelen(a);\n+\tregister int len = ce_namelen(a);\n  \treturn ce_namelen(b) == len &&\n  \t\t!memcmp(a->name, b->name, len);\n  }\n@@ -113,7 +115,7 @@ static struct cache_entry *merge_entries\n  \t\t\t\t\t struct cache_entry *b,\n  \t\t\t\t\t struct cache_entry *c)\n  {\n-\tint len = ce_namelen(a);\n+\tregister int len = ce_namelen(a);\n\n  \t/*\n  \t * Are they all the same filename? We won't do\n@@ -221,7 +223,8 @@ static char *read_tree_usage = \"read-tre\n\n  int main(int argc, char **argv)\n  {\n-\tint i, newfd, merge;\n+\tregister unsigned int i,merge;\n+\tregister int newfd;\n  \tunsigned char sha1[20];\n  \tstatic char lockfile[MAXPATHLEN+1];\n  \tconst char *indexfile = get_index_file();\ndiff -Npru git-0.6/revision.h git-0.6-ott/revision.h\n--- git-0.6/revision.h\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/revision.h\t2005-04-24 18:43:36.000000000 +0200\n@@ -33,7 +33,8 @@ static int nr_revs, rev_allocs;\n\n  static int find_rev(unsigned char *sha1)\n  {\n-\tint first = 0, last = nr_revs;\n+\tregister unsigned int first = 0;\n+\tregister int last = nr_revs;\n\n  \twhile (first < last) {\n  \t\tint next = (first + last) / 2;\ndiff -Npru git-0.6/rev-tree.c git-0.6-ott/rev-tree.c\n--- git-0.6/rev-tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/rev-tree.c\t2005-04-24 18:46:47.000000000 +0200\n@@ -32,7 +32,7 @@ static void read_cache_file(const char *\n   */\n  static int interesting(struct commit *rev)\n  {\n-\tunsigned mask = rev->object.flags;\n+\tregister unsigned int mask = rev->object.flags;\n\n  \tif (!mask)\n  \t\treturn 0;\n@@ -77,8 +77,8 @@ void process_commit(unsigned char *sha1)\n   */\n  int main(int argc, char **argv)\n  {\n-\tint i;\n-\tint nr = 0;\n+\tregister unsigned int i;\n+\tregister unsigned int nr = 0;\n  \tunsigned char sha1[MAX_COMMITS][20];\n\n  \t/*\ndiff -Npru git-0.6/sha1_file.c git-0.6-ott/sha1_file.c\n--- git-0.6/sha1_file.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/sha1_file.c\t2005-04-24 20:46:32.000000000 +0200\n@@ -6,6 +6,7 @@\n   * This handles basic git sha1 object files - packing, unpacking,\n   * creation etc.\n   */\n+#include <stddef.h>\n  #include <stdarg.h>\n  #include \"cache.h\"\n\n@@ -24,7 +25,7 @@ static unsigned hexval(char c)\n\n  int get_sha1_hex(const char *hex, unsigned char *sha1)\n  {\n-\tint i;\n+\tregister unsigned int i;\n  \tfor (i = 0; i < 20; i++) {\n  \t\tunsigned int val = (hexval(hex[0]) << 4) | hexval(hex[1]);\n  \t\tif (val & ~0xff)\n@@ -40,7 +41,7 @@ char * sha1_to_hex(const unsigned char *\n  \tstatic char buffer[50];\n  \tstatic const char hex[] = \"0123456789abcdef\";\n  \tchar *buf = buffer;\n-\tint i;\n+\tregister unsigned short int i;\n\n  \tfor (i = 0; i < 20; i++) {\n  \t\tunsigned int val = *sha1++;\n@@ -57,7 +58,7 @@ char * sha1_to_hex(const unsigned char *\n   */\n  char *sha1_file_name(const unsigned char *sha1)\n  {\n-\tint i;\n+\tregister unsigned short int i;\n  \tstatic char *name, *base;\n\n  \tif (!base) {\n@@ -96,7 +97,7 @@ int check_sha1_signature(unsigned char *\n  void *map_sha1_file(const unsigned char *sha1, unsigned long *size)\n  {\n  \tchar *filename = sha1_file_name(sha1);\n-\tint fd = open(filename, O_RDONLY);\n+\tregister int fd = open(filename, O_RDONLY);\n  \tstruct stat st;\n  \tvoid *map;\n\n@@ -118,7 +119,7 @@ void *map_sha1_file(const unsigned char\n\n  void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, \nunsigned long *size)\n  {\n-\tint ret, bytes;\n+\tregister int ret, bytes;\n  \tz_stream stream;\n  \tchar buffer[8192];\n  \tchar *buf;\n@@ -173,7 +174,7 @@ void *read_tree_with_tree_or_commit_sha1\n  \tchar type[20];\n  \tvoid *buffer;\n  \tunsigned long isize;\n-\tint was_commit = 0;\n+\tregister unsigned short int was_commit = 0;\n  \tunsigned char tree_sha1[20];\n\n  \tbuffer = read_sha1_file(sha1, type, &isize);\n@@ -208,13 +209,13 @@ void *read_tree_with_tree_or_commit_sha1\n\n  int write_sha1_file(char *buf, unsigned len, unsigned char *returnsha1)\n  {\n-\tint size;\n+\tregister size_t size;\n  \tchar *compressed;\n  \tz_stream stream;\n  \tunsigned char sha1[20];\n  \tSHA_CTX c;\n  \tchar *filename;\n-\tint fd;\n+\tregister int fd;\n\n  \t/* Sha1.. */\n  \tSHA1_Init(&c);\n@@ -264,9 +265,9 @@ static inline int collision_check(char *\n  {\n  #ifdef COLLISION_CHECK\n  \tvoid *map;\n-\tint fd = open(filename, O_RDONLY);\n+\tregister int fd = open(filename, O_RDONLY);\n  \tstruct stat st;\n-\tint cmp;\n+\tregister int cmp;\n\n  \t/* Unreadable object, or object went away? Strange. */\n  \tif (fd < 0)\n@@ -290,7 +291,7 @@ static inline int collision_check(char *\n  int write_sha1_buffer(const unsigned char *sha1, void *buf, unsigned \nint size)\n  {\n  \tchar *filename = sha1_file_name(sha1);\n-\tint fd;\n+\tregister int fd;\n\n  \tfd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);\n  \tif (fd < 0) {\ndiff -Npru git-0.6/show-diff.c git-0.6-ott/show-diff.c\n--- git-0.6/show-diff.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/show-diff.c\t2005-04-24 19:53:09.000000000 +0200\n@@ -38,7 +38,7 @@ static void prepare_diff_cmd(void)\n  static char *sq_expand(char *src)\n  {\n  \tstatic char *buf = NULL;\n-\tint cnt, c;\n+\tregister int cnt, c;\n  \tchar *cp;\n\n  \t/* count bytes needed to store the quoted string. */\n@@ -71,7 +71,7 @@ static void show_differences(char *name,\n  \tint cmd_size = strlen(name_sq) + strlen(label_sq) * 2 +\n  \t\tstrlen(diff_cmd) + strlen(diff_opts) + strlen(diff_arg);\n  \tchar *cmd = malloc(cmd_size);\n-\tint next_at;\n+\tregister int next_at;\n\n  \tfflush(stdout);\n  \tnext_at = snprintf(cmd, cmd_size, diff_cmd, label_sq, label_sq);\n@@ -106,7 +106,7 @@ static const char *show_diff_usage = \"sh\n\n  static int matches_pathspec(struct cache_entry *ce, char **spec, int cnt)\n  {\n-\tint i;\n+\tregister int i;\n  \tint namelen = ce_namelen(ce);\n  \tfor (i = 0; i < cnt; i++) {\n  \t\tint speclen = strlen(spec[i]);\n@@ -121,12 +121,12 @@ static int matches_pathspec(struct cache\n\n  int main(int argc, char **argv)\n  {\n-\tint silent = 0;\n-\tint silent_on_nonexisting_files = 0;\n-\tint machine_readable = 0;\n-\tint reverse = 0;\n-\tint entries = read_cache();\n-\tint i;\n+\tregister unsigned short int silent = 0;\n+\tregister unsigned short int silent_on_nonexisting_files = 0;\n+\tregister unsigned short int machine_readable = 0;\n+\tregister unsigned short int reverse = 0;\n+\tregister int entries = read_cache();\n+\tregister int i;\n\n  \twhile (1 < argc && argv[1][0] == '-') {\n  \t\tif  (!strcmp(argv[1], \"-R\"))\n@@ -153,7 +153,7 @@ int main(int argc, char **argv)\n  \tfor (i = 0; i < entries; i++) {\n  \t\tstruct stat st;\n  \t\tstruct cache_entry *ce = active_cache[i];\n-\t\tint changed;\n+\t\tregister unsigned short int changed;\n  \t\tunsigned long size;\n  \t\tchar type[20];\n  \t\tvoid *old;\ndiff -Npru git-0.6/show-files.c git-0.6-ott/show-files.c\n--- git-0.6/show-files.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/show-files.c\t2005-04-24 19:08:07.000000000 +0200\n@@ -5,6 +5,7 @@\n   *\n   * Copyright (C) Linus Torvalds, 2005\n   */\n+#include <stddef.h>\n  #include <dirent.h>\n\n  #include \"cache.h\"\n@@ -91,14 +92,14 @@ static int cmp_name(const void *p1, cons\n  {\n  \tconst char *n1 = *(const char **)p1;\n  \tconst char *n2 = *(const char **)p2;\n-\tint l1 = strlen(n1), l2 = strlen(n2);\n+\tregister size_t l1 = strlen(n1), l2 = strlen(n2);\n\n  \treturn cache_name_compare(n1, l1, n2, l2);\n  }\n\n  static void show_files(void)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \t/* For cached/deleted files we don't need to even do the readdir */\n  \tif (show_others | show_ignored) {\n@@ -142,7 +143,7 @@ static void show_files(void)\n\n  int main(int argc, char **argv)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \tfor (i = 1; i < argc; i++) {\n  \t\tchar *arg = argv[i];\ndiff -Npru git-0.6/tree.c git-0.6-ott/tree.c\n--- git-0.6/tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/tree.c\t2005-04-24 19:52:40.000000000 +0200\n@@ -1,6 +1,7 @@\n  #include \"tree.h\"\n  #include \"blob.h\"\n  #include \"cache.h\"\n+#include <stddef.h>\n  #include <stdlib.h>\n\n  const char *tree_type = \"tree\";\n@@ -40,7 +41,7 @@ int parse_tree(struct tree *item)\n  \t\t\t     sha1_to_hex(item->object.sha1));\n  \twhile (size) {\n  \t\tstruct object *obj;\n-\t\tint len = 1+strlen(bufptr);\n+\t\tsize_t len = 1+strlen(bufptr);\n  \t\tunsigned char *file_sha1 = bufptr + len;\n  \t\tchar *path = strchr(bufptr, ' ');\n  \t\tunsigned int mode;\ndiff -Npru git-0.6/unpack-file.c git-0.6-ott/unpack-file.c\n--- git-0.6/unpack-file.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/unpack-file.c\t2005-04-24 19:11:17.000000000 +0200\n@@ -6,7 +6,7 @@ static char *create_temp_file(unsigned c\n  \tvoid *buf;\n  \tchar type[100];\n  \tunsigned long size;\n-\tint fd;\n+\tregister int fd;\n\n  \tbuf = read_sha1_file(sha1, type, &size);\n  \tif (!buf || strcmp(type, \"blob\"))\ndiff -Npru git-0.6/update-cache.c git-0.6-ott/update-cache.c\n--- git-0.6/update-cache.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/update-cache.c\t2005-04-24 19:46:03.000000000 +0200\n@@ -3,6 +3,8 @@\n   *\n   * Copyright (C) Linus Torvalds, 2005\n   */\n+#include <stddef.h>\n+\n  #include \"cache.h\"\n\n  /*\n@@ -17,11 +19,11 @@ static int allow_add = 0, allow_remove =\n  static int index_fd(unsigned char *sha1, int fd, struct stat *st)\n  {\n  \tz_stream stream;\n-\tunsigned long size = st->st_size;\n-\tint max_out_bytes = size + 200;\n+\tregister unsigned long size = st->st_size;\n+\tregister int max_out_bytes = size + 200;\n  \tvoid *out = malloc(max_out_bytes);\n  \tvoid *metadata = malloc(200);\n-\tint metadata_size;\n+\tregister int metadata_size;\n  \tvoid *in;\n  \tSHA_CTX c;\n\n@@ -87,10 +89,11 @@ static void fill_stat_cache_info(struct\n\n  static int add_file_to_cache(char *path)\n  {\n-\tint size, namelen;\n+\tregister int size;\n+\tregister size_t namelen;\n  \tstruct cache_entry *ce;\n  \tstruct stat st;\n-\tint fd;\n+\tregister int fd;\n\n  \tfd = open(path, O_RDONLY);\n  \tif (fd < 0) {\n@@ -123,7 +126,7 @@ static int match_data(int fd, void *buff\n  {\n  \twhile (size) {\n  \t\tchar compare[1024];\n-\t\tint ret = read(fd, compare, sizeof(compare));\n+\t\tregister int ret = read(fd, compare, sizeof(compare));\n\n  \t\tif (ret <= 0 || ret > size || memcmp(buffer, compare, ret))\n  \t\t\treturn -1;\n@@ -135,8 +138,8 @@ static int match_data(int fd, void *buff\n\n  static int compare_data(struct cache_entry *ce, unsigned long \nexpected_size)\n  {\n-\tint match = -1;\n-\tint fd = open(ce->name, O_RDONLY);\n+\tregister int match = -1;\n+\tregister int fd = open(ce->name, O_RDONLY);\n\n  \tif (fd >= 0) {\n  \t\tvoid *buffer;\n@@ -169,7 +172,7 @@ static struct cache_entry *refresh_entry\n  {\n  \tstruct stat st;\n  \tstruct cache_entry *updated;\n-\tint changed, size;\n+\tregister int changed, size;\n\n  \tif (stat(ce->name, &st) < 0)\n  \t\treturn NULL;\n@@ -197,7 +200,7 @@ static struct cache_entry *refresh_entry\n\n  static void refresh_cache(void)\n  {\n-\tint i;\n+\tregister unsigned int i;\n\n  \tfor (i = 0; i < active_nr; i++) {\n  \t\tstruct cache_entry *ce, *new;\n@@ -231,7 +234,7 @@ static void refresh_cache(void)\n   */\n  static int verify_path(char *path)\n  {\n-\tchar c;\n+\tregister char c;\n\n  \tgoto inside;\n  \tfor (;;) {\n@@ -250,7 +253,8 @@ inside:\n\n  static int add_cacheinfo(char *arg1, char *arg2, char *arg3)\n  {\n-\tint size, len;\n+\tregister int size;\n+\tregister size_t len;\n  \tunsigned int mode;\n  \tunsigned char sha1[20];\n  \tstruct cache_entry *ce;\n@@ -284,8 +288,8 @@ static void remove_lock_file(void)\n\n  int main(int argc, char **argv)\n  {\n-\tint i, newfd, entries;\n-\tint allow_options = 1;\n+\tregister int i, newfd, entries;\n+\tregister unsigned short int allow_options = 1;\n  \tstatic char lockfile[MAXPATHLEN+1];\n  \tconst char *indexfile = get_index_file();\n\ndiff -Npru git-0.6/write-tree.c git-0.6-ott/write-tree.c\n--- git-0.6/write-tree.c\t2005-04-21 19:58:47.000000000 +0200\n+++ git-0.6-ott/write-tree.c\t2005-04-24 19:22:22.000000000 +0200\n@@ -8,7 +8,7 @@\n  static int check_valid_sha1(unsigned char *sha1)\n  {\n  \tchar *filename = sha1_file_name(sha1);\n-\tint ret;\n+\tregister int ret;\n\n  \t/* If we were anal, we'd check that the sha1 of the contents actually \nmatches */\n  \tret = access(filename, R_OK);\n@@ -32,9 +32,9 @@ static int prepend_integer(char *buffer,\n  static int write_tree(struct cache_entry **cachep, int maxentries, \nconst char *base, int baselen, unsigned char *returnsha1)\n  {\n  \tunsigned char subdir_sha1[20];\n-\tunsigned long size, offset;\n+\tregister unsigned long size, offset;\n  \tchar *buffer;\n-\tint i, nr;\n+\tregister int i, nr;\n\n  \t/* Guess at some random initial size */\n  \tsize = 8192;\n@@ -100,8 +100,8 @@ static int write_tree(struct cache_entry\n\n  int main(int argc, char **argv)\n  {\n-\tint i, unmerged;\n-\tint entries = read_cache();\n+\tregister int i, unmerged;\n+\tregister int entries = read_cache();\n  \tunsigned char sha1[20];\n\n  \tif (entries <= 0)\n"},{"id":"1606","messageId":"426CD703.5040009@exactcode.de","threadId":"306","inReplyTo":"426CD1F1.2010101@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Rene Rebe","fromEmail":"rene@exactcode.de","sentAt":"2005-04-25T11:39:47Z","receivedAt":"2005-04-25T11:39:47Z","isPatch":true,"sender":{"key":"rene@exactcode.de","avatar":null},"body":"Hi,\n\nMatthias-Christian Ott wrote:\n> The \"git\" didn't try store small variables, which aren't referenced, in \n> the processor registers. It also didn't use the size_t type. I corrected \n> a C++ style comment too.\n\nWell, modern compilers take register as a non-binding hint. Your \nregister storage specification for those loop counters will not make any \nchange. You have not looked into the resulting binary?\n\nAlso // is valid C99 ...\n\nYours,\n\n-- \nRené Rebe - Rubensstr. 64 - 12157 Berlin (Europe / Germany)\n             http://www.exactcode.de/ | http://www.t2-project.org/\n             +49 (0)30  255 897 45\n\n"},{"id":"1608","messageId":"20050425123236.GC26665@pasky.ji.cz","threadId":"306","inReplyTo":"426CD1F1.2010101@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-25T12:32:36Z","receivedAt":"2005-04-25T12:32:36Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Mon, Apr 25, 2005 at 01:18:09PM CEST, I got a letter\nwhere Matthias-Christian Ott <matthias.christian@tiscali.de> told me that...\n> The \"git\" didn't try store small variables, which aren't referenced, in \n> the processor registers. It also didn't use the size_t type. I corrected \n> a C++ style comment too.\n\nHonestly, I don't think using the register keyword helps anything but to\nmake the code less readable.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1609","messageId":"426CE904.9010505@tiscali.de","threadId":"306","inReplyTo":"426CD703.5040009@exactcode.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T12:56:36Z","receivedAt":"2005-04-25T12:56:36Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"Rene Rebe wrote:\n> Hi,\n> \n> Matthias-Christian Ott wrote:\n> \n>> The \"git\" didn't try store small variables, which aren't referenced, \n>> in the processor registers. It also didn't use the size_t type. I \n>> corrected a C++ style comment too.\n> \n> \n> Well, modern compilers take register as a non-binding hint. Your \n> register storage specification for those loop counters will not make any \n> change. You have not looked into the resulting binary?\n> \n> Also // is valid C99 ...\n> \n> Yours,\n> \nBut if you use only /* */ comments and there's a // comment it looks \nugly :).\n\nI've disassembled the code and it for me (I'm not a professional \nassembler coder) it looks like it's stored in a register because the ebp \noffsets are smaller and the gcc (4.0) wouldn't cause an error if you \nreference them.\n\nMatthias-Christian Ott\n"},{"id":"1610","messageId":"426CEA3B.50300@tiscali.de","threadId":"306","inReplyTo":"426CE904.9010505@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T13:01:47Z","receivedAt":"2005-04-25T13:01:47Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"Matthias-Christian Ott wrote:\n> Rene Rebe wrote:\n> \n>> Hi,\n>>\n>> Matthias-Christian Ott wrote:\n>>\n>>> The \"git\" didn't try store small variables, which aren't referenced, \n>>> in the processor registers. It also didn't use the size_t type. I \n>>> corrected a C++ style comment too.\n>>\n>>\n>>\n>> Well, modern compilers take register as a non-binding hint. Your \n>> register storage specification for those loop counters will not make \n>> any change. You have not looked into the resulting binary?\n>>\n>> Also // is valid C99 ...\n>>\n>> Yours,\n>>\n> But if you use only /* */ comments and there's a // comment it looks \n> ugly :).\n> \n> I've disassembled the code and it for me (I'm not a professional \n> assembler coder) it looks like it's stored in a register because the ebp \n> offsets are smaller and the gcc (4.0) wouldn't cause an error if you \n> reference them.\n> \n> Matthias-Christian Ott\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \nHere's some example code (diff of the assembler codes) which shows what \nI mean:\n\n-       movl    %eax, -8(%ebp)\n+       movl    %eax, -4(%ebp)\n[..]\n-       leal    1(%eax), %ecx\n-       movl    -52(%ebp), %edx\n+       leal    1(%eax), %edx\n         movl    12(%ebp), %eax\n-       subl    %edx, %eax\n-       movl    %eax, %edx\n-       movl    -52(%ebp), %eax\n+       movl    %eax, %ecx\n+       subl    -80(%ebp), %ecx\n+       movl    -80(%ebp), %eax\n         sall    $2, %eax\n         movl    %eax, %ebx\n         addl    8(%ebp), %ebx\n\n"},{"id":"1611","messageId":"84144f02050425060763f92b7@mail.gmail.com","threadId":"306","inReplyTo":"20050425123236.GC26665@pasky.ji.cz","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Pekka Enberg","fromEmail":"penberg@gmail.com","sentAt":"2005-04-25T13:07:20Z","receivedAt":"2005-04-25T13:07:20Z","isPatch":true,"sender":{"key":"penberg@gmail.com","avatar":null},"body":"Hi,\n\nOn 4/25/05, Petr Baudis <pasky@ucw.cz> wrote:\n> Honestly, I don't think using the register keyword helps anything but to\n> make the code less readable.\n\nIndeed. The use of 'register' keyword blindly can actually make the\ngenerated code _worse_ as it taking away one register from the\ncompiler's register allocator.\n\n                        Pekka\n"},{"id":"1613","messageId":"Pine.LNX.4.58.0504250751330.18901@ppc970.osdl.org","threadId":"306","inReplyTo":"426CD1F1.2010101@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-25T14:52:31Z","receivedAt":"2005-04-25T14:52:31Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n>\n> The \"git\" didn't try store small variables, which aren't referenced, in \n> the processor registers. It also didn't use the size_t type. I corrected \n> a C++ style comment too.\n\nWhat kind of ancient C standard are you working against?\n\n// isn't \"C++\" any more, and \"register\" variables are sooo 60's, man.\n\nPass the toke,\n\n\t\tLinus\n"},{"id":"1619","messageId":"426D21FE.3040401@tiscali.de","threadId":"306","inReplyTo":"Pine.LNX.4.58.0504250751330.18901@ppc970.osdl.org","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T16:59:42Z","receivedAt":"2005-04-25T16:59:42Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"Linus Torvalds wrote:\n> \n> On Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n> \n>>The \"git\" didn't try store small variables, which aren't referenced, in \n>>the processor registers. It also didn't use the size_t type. I corrected \n>>a C++ style comment too.\n> \n> \n> What kind of ancient C standard are you working against?\n> \n> // isn't \"C++\" any more, and \"register\" variables are sooo 60's, man.\n> \n> Pass the toke,\n> \n> \t\tLinus\n> \n\"register\" and \"auto\" variables aren't relicts of the 60's,  they're a \npart of the ISO-C 99 standard, I'm following, \"man\".\n\nAnd if you think \"register\" variables are outdated, please remove the \nCONFIG_REGPARM option from the Kernel source.\n\nRemoving a \"//\" comment makes sense in this case because a \"//\" comment \nbetween hundrets of \"/* */\" comments looks extremly ugly and shows that \nthe source is \"patchworked\" and unstructured.\n\nToday a lot of people forget about the basic rules of coding. You too. :)\n\nMatthias-Christian Ott\n\nLiterature:\n[1] Dr.-Ing. Ludwig Claßen, Dipl.-Math. Ulrich Oefler: Unix und C: Ein \nAnwenderbuch; VEB Verlag Technik Berlin; 1990\n[2] Erik de Castro Lopo, Peter Aitken, Bradley L. Jones: Teach Yourself \nC for Linux Programming in 21 Days; SAMS Publishing; 1999\n\n"},{"id":"1621","messageId":"20050425171234.GP24187@lug-owl.de","threadId":"306","inReplyTo":"426D21FE.3040401@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Jan-Benedict Glaw","fromEmail":"jbglaw@lug-owl.de","sentAt":"2005-04-25T17:12:34Z","receivedAt":"2005-04-25T17:12:34Z","isPatch":true,"sender":{"key":"jbglaw@lug-owl.de","avatar":null},"body":"On Mon, 2005-04-25 18:59:42 +0200, Matthias-Christian Ott <matthias.christian@tiscali.de> wrote:\n\n[\"register\" variables]\n\n> Literature:\n\n> [2] Erik de Castro Lopo, Peter Aitken, Bradley L. Jones: Teach Yourself \n> C for Linux Programming in 21 Days; SAMS Publishing; 1999\n\nYeah, \"register\" is what you use after 21 days of programming\npracitce...\n\nSCNR, JBG\n\n-- \nJan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _\n\"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O\n fuer einen Freien Staat voll Freier Bürger\" | im Internet! |   im Irak!   O O O\nret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));\n"},{"id":"1622","messageId":"20050425171359.GN10806@cip.informatik.uni-erlangen.de","threadId":"306","inReplyTo":"20050425171234.GP24187@lug-owl.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2005-04-25T17:13:59Z","receivedAt":"2005-04-25T17:13:59Z","isPatch":true,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"Hello,\n\n> Yeah, \"register\" is what you use after 21 days of programming\n> pracitce...\n\nactually it is introduced on day 2.\n\n\tThomas\n"},{"id":"1626","messageId":"20050425171821.GQ24187@lug-owl.de","threadId":"306","inReplyTo":"20050425171359.GN10806@cip.informatik.uni-erlangen.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Jan-Benedict Glaw","fromEmail":"jbglaw@lug-owl.de","sentAt":"2005-04-25T17:18:21Z","receivedAt":"2005-04-25T17:18:21Z","isPatch":true,"sender":{"key":"jbglaw@lug-owl.de","avatar":null},"body":"On Mon, 2005-04-25 19:13:59 +0200, Thomas Glanzmann <sithglan@stud.uni-erlangen.de> wrote:\n\n> > Yeah, \"register\" is what you use after 21 days of programming\n> > pracitce...\n> \n> actually it is introduced on day 2.\n\n...and excessive use of \"goto\" being on day one?\n\nMfG, JBG\n\n-- \nJan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _\n\"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O\n fuer einen Freien Staat voll Freier Bürger\" | im Internet! |   im Irak!   O O O\nret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));\n"},{"id":"1625","messageId":"200504251722.j3PHMalh017453@turing-police.cc.vt.edu","threadId":"306","inReplyTo":"426D21FE.3040401@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"","fromEmail":"valdis.kletnieks@vt.edu","sentAt":"2005-04-25T17:22:36Z","receivedAt":"2005-04-25T17:22:36Z","isPatch":true,"sender":{"key":"valdis.kletnieks@vt.edu","avatar":null},"body":"On Mon, 25 Apr 2005 18:59:42 +0200, Matthias-Christian Ott said:\n\n> And if you think \"register\" variables are outdated, please remove the \n> CONFIG_REGPARM option from the Kernel source.\n\nI think you fail to understand the difference between what CONFIG_REGPARM does\n(namely, controlling the way parameters are passed to function calls) and what\nthe 'register' declaration does....\n\n> [2] Erik de Castro Lopo, Peter Aitken, Bradley L. Jones: Teach Yourself \n> C for Linux Programming in 21 Days; SAMS Publishing; 1999\n\nUmm.. Yeah.  \"Teach yourself FOO in 21 days\".  Quite the outstanding authority\nto cite.  Gotta love the publisher too.. ;)\n\n"},{"id":"1623","messageId":"Pine.LNX.4.58.0504251021280.18901@ppc970.osdl.org","threadId":"306","inReplyTo":"426D21FE.3040401@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-25T17:23:40Z","receivedAt":"2005-04-25T17:23:40Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n>\n> \"register\" and \"auto\" variables aren't relicts of the 60's,  they're a \n> part of the ISO-C 99 standard, I'm following, \"man\".\n\nThey _are_ relicts of the 60's. It's just that the C standard hasn't ever \nhad the reason to remove them.\n\n> And if you think \"register\" variables are outdated, please remove the \n> CONFIG_REGPARM option from the Kernel source.\n\nThat does something totally different. And doesn't use \"register\" at all.\n\nPass the toke, you've been hogging the drugs for way too long.\n\n\t\tLinus\n"},{"id":"1629","messageId":"d120d500050425103822c3c9a1@mail.gmail.com","threadId":"306","inReplyTo":"426D21FE.3040401@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Dmitry Torokhov","fromEmail":"dmitry.torokhov@gmail.com","sentAt":"2005-04-25T17:38:20Z","receivedAt":"2005-04-25T17:38:20Z","isPatch":true,"sender":{"key":"dmitry.torokhov@gmail.com","avatar":null},"body":"On 4/25/05, Matthias-Christian Ott <matthias.christian@tiscali.de> wrote:\n> \"register\" and \"auto\" variables aren't relicts of the 60's,  they're a\n> part of the ISO-C 99 standard, I'm following, \"man\".\n...\n> [2] Erik de Castro Lopo, Peter Aitken, Bradley L. Jones: Teach Yourself\n> C for Linux Programming in 21 Days; SAMS Publishing; 1999\n\nIt must be \"Teach yourself C for Gentoo Linux Programming...\" \"...\nGentoo rocks! I changed all my variables to 'register' and now my\nkernel runs 3x times faster than RehHat one\" :)\n\nSorry, couldn't resist...\n\n-- \nDmitry\n"},{"id":"1633","messageId":"426D319B.2040805@dwheeler.com","threadId":"306","inReplyTo":"426CD703.5040009@exactcode.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"David A. Wheeler","fromEmail":"dwheeler@dwheeler.com","sentAt":"2005-04-25T18:06:19Z","receivedAt":"2005-04-25T18:06:19Z","isPatch":true,"sender":{"key":"dwheeler@dwheeler.com","avatar":"https://avatars.githubusercontent.com/u/813150?v=4"},"body":"Rene Rebe wrote:\n\n> Hi,\n>\n> Matthias-Christian Ott wrote:\n>\n>> The \"git\" didn't try store small variables, which aren't referenced, \n>> in the processor registers. It also didn't use the size_t type. I \n>> corrected a C++ style comment too.\n>\n>\n> Well, modern compilers take register as a non-binding hint. Your \n> register storage specification for those loop counters will not make \n> any change. You have not looked into the resulting binary?\n\nIndeed, register was ALWAYS a non-binding hint. Today,\nunless you have specific measurements showing that adding \"register\"\nat some point improves the performance for a (somewhat common) situation,\nyou're better off NOT including \"register\" nowadays.  Today's compilers\nare generally better at allocating registers than \npeople-who-have-little-time.\nPremature optimization is the root of all kinds of evil...\n\n> Also // is valid C99 ...\n\nIt's not, strictly speaking, okay on old pre-C99 compilers.\nBut in practice, practically all C compilers from the last 10+ years\nhave accepted // comments as a very popular extension.\nSo using \"//\" is unlikely to be a portability problem, even on semi-old \ncompilers.\n\n--- David A. Wheeler\n\n"},{"id":"1636","messageId":"426D33BA.8040604@tiscali.de","threadId":"306","inReplyTo":"Pine.LNX.4.58.0504251021280.18901@ppc970.osdl.org","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T18:15:22Z","receivedAt":"2005-04-25T18:15:22Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"Linus Torvalds wrote:\n> \n> On Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n> \n>>\"register\" and \"auto\" variables aren't relicts of the 60's,  they're a \n>>part of the ISO-C 99 standard, I'm following, \"man\".\n> \n> \n> They _are_ relicts of the 60's. It's just that the C standard hasn't ever \n> had the reason to remove them.\n> \n> \n>>And if you think \"register\" variables are outdated, please remove the \n>>CONFIG_REGPARM option from the Kernel source.\n> \n> \n> That does something totally different. And doesn't use \"register\" at all.\n> \n> Pass the toke, you've been hogging the drugs for way too long.\n> \n> \t\tLinus\n> \nBut this makes, like \"register\",  direct use of processor registers (it stores int arguments in eax, ebx, etc.).\n\nMatthias-Christian Ott\n"},{"id":"1637","messageId":"426D35AC.9060605@tiscali.de","threadId":"306","inReplyTo":"20050425171821.GQ24187@lug-owl.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Matthias-Christian Ott","fromEmail":"matthias.christian@tiscali.de","sentAt":"2005-04-25T18:23:40Z","receivedAt":"2005-04-25T18:23:40Z","isPatch":true,"sender":{"key":"matthias.christian@tiscali.de","avatar":null},"body":"Jan-Benedict Glaw wrote:\n> On Mon, 2005-04-25 19:13:59 +0200, Thomas Glanzmann <sithglan@stud.uni-erlangen.de> wrote:\n> \n> \n>>>Yeah, \"register\" is what you use after 21 days of programming\n>>>pracitce...\n>>\n>>actually it is introduced on day 2.\n> \n> \n> ...and excessive use of \"goto\" being on day one?\n> \n> MfG, JBG\n> \nStay serious. The book only teaches you ISO-C 99 like many other books. So where's your problem?\n\nA good old german adage says: \"Das ist so schrecklich, dass heute jeder Idiot zu allem eine Meinung hat.\" (Dieter Nuhr (http://de.wikiquote.org/wiki/Dieter_Nuhr))\n"},{"id":"1640","messageId":"Pine.LNX.4.58.0504251147290.18901@ppc970.osdl.org","threadId":"306","inReplyTo":"426D33BA.8040604@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-25T18:50:29Z","receivedAt":"2005-04-25T18:50:29Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n>\n> But this makes, like \"register\", direct use of processor registers (it\n> stores int arguments in eax, ebx, etc.).\n\nNo. It make _unlike_ \"register\", direct use of processor registers.\n\nThe \"register\" keyword does _not_ use processor registers. It's just \nsyntactic fluff, and tells the compiler exactly one thing:\n\n - that the compiler should warn if you take the address of such a thing.\n\nIn addition, the compiler may generate code that takes it into account, \nwhich most likely means _worse_ code than if it didn't take it into \naccount.\n\nIn contrast regparm() actually says something very relevant: it says that \nthe function uses a totally different calling convention.\n\n\t\tLinus\n"},{"id":"1641","messageId":"200504251855.j3PItHQs021408@turing-police.cc.vt.edu","threadId":"306","inReplyTo":"426D33BA.8040604@tiscali.de","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"","fromEmail":"valdis.kletnieks@vt.edu","sentAt":"2005-04-25T18:55:16Z","receivedAt":"2005-04-25T18:55:16Z","isPatch":true,"sender":{"key":"valdis.kletnieks@vt.edu","avatar":null},"body":"On Mon, 25 Apr 2005 20:15:22 +0200, Matthias-Christian Ott said:\n\n> But this makes, like \"register\",  direct use of processor registers (it stores int arguments in eax, ebx, etc.).\n\n`-mregparm=NUM'\n     Control how many registers are used to pass integer arguments.  By\n     default, no registers are used to pass arguments, and at most 3\n     registers can be used.  You can control this behavior for a\n     specific function by using the function attribute `regparm'.\n     *Note Function Attributes::.\n\n     *Warning:* if you use this switch, and NUM is nonzero, then you\n     must build all modules with the same value, including any\n     libraries.  This includes the system libraries and startup modules.\n\nIf it weren't for that *warning*, you could get away with making this another\nauto-optimizable value (similar to register allocation inside a function).\nAlas, the caller and called functions can be in different .o files, and as\na result, you need to be able to specify the NUM to use to each invocation\nof gcc involved, as there's an ABI change involved....\n\n> Stay serious. The book only teaches you ISO-C 99 like many other books. So\n> where's your problem?\n\nThe problem is the supposition that the implied 3 week's experience in a\nlanguage makes anybody qualified to comment on how to use it truly effectively\n(for that matter, I've been programming in C since SunOS 3.2, literally 2\ndecades ago, and I'm still finding little corners I didn't previously know...)\n\n"},{"id":"1645","messageId":"426D4873.5070607@khandalf.com","threadId":"306","inReplyTo":"200504251855.j3PItHQs021408@turing-police.cc.vt.edu","subject":"Re: the REGISTER thread","fromName":"Brian O'Mahoney","fromEmail":"omb@khandalf.com","sentAt":"2005-04-25T19:43:47Z","receivedAt":"2005-04-25T19:43:47Z","isPatch":false,"sender":{"key":"omb@khandalf.com","avatar":null},"body":"Enough already, school is out!\n\nBrian\n"},{"id":"1650","messageId":"1114462210.8442.54.camel@laptopd505.fenrus.org","threadId":"306","inReplyTo":"Pine.LNX.4.58.0504251147290.18901@ppc970.osdl.org","subject":"Re: [PATCH GIT 0.6] make use of register variables & size_t","fromName":"Arjan van de Ven","fromEmail":"arjan@infradead.org","sentAt":"2005-04-25T20:50:09Z","receivedAt":"2005-04-25T20:50:09Z","isPatch":true,"sender":{"key":"arjan@infradead.org","avatar":"https://gravatar.com/avatar/42631f2338fc04830b31b08bc42b6575a3547fba469bd73ba7e1f237d650986a?d=mp&s=160"},"body":"On Mon, 2005-04-25 at 11:50 -0700, Linus Torvalds wrote:\n> \n> On Mon, 25 Apr 2005, Matthias-Christian Ott wrote:\n> >\n> > But this makes, like \"register\", direct use of processor registers (it\n> > stores int arguments in eax, ebx, etc.).\n> \n> No. It make _unlike_ \"register\", direct use of processor registers.\n> \n> The \"register\" keyword does _not_ use processor registers. It's just \n> syntactic fluff, and tells the compiler exactly one thing:\n> \n>  - that the compiler should warn if you take the address of such a thing.\n> \n> In addition, the compiler may generate code that takes it into account, \n> which most likely means _worse_ code than if it didn't take it into \n> account.\n\nafaik gcc just otherwise ignores it entirely.\n\n\n"}]}