Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ots.cc

Issue 10273021: Revive Tag() function (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ots.h" 5 #include "ots.h"
6 6
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <zlib.h> 8 #include <zlib.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 hunks_.push_back(p); 76 hunks_.push_back(p);
77 return p; 77 return p;
78 } 78 }
79 79
80 private: 80 private:
81 std::vector<uint8_t*> hunks_; 81 std::vector<uint8_t*> hunks_;
82 }; 82 };
83 83
84 // Use a macro instead of a function because gcc 4.4.3 creates static 84 // Use a macro instead of a function because gcc 4.4.3 creates static
85 // initializers in that case. 85 // initializers in that case.
86 #if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) 86 // Try endianness checks with zero, one and two leading underscores,
Yusuke Sato 2012/05/01 02:23:31 The #ifdefs look too complex to me. What about rev
bashi 2012/05/01 04:05:49 Done. Thank you for suggestion!
87 #define TAG(d, c, b, a) (a | (b << 8) | (c << 16) | (d << 24)) 87 // as the symbols actually defined seem to vary between systems. (Sigh.)
88 #else 88 #if defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) && defined(BYTE_ORDER)
89 #define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) 89 # if BYTE_ORDER == BIG_ENDIAN
90 # define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d)
91 # elif BYTE_ORDER == LITTLE_ENDIAN
92 # define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24))
93 # else
94 # error "unsupported byte order!"
95 # endif
96 #elif defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) && defined(_BYTE_ORDER)
97 # if _BYTE_ORDER == _BIG_ENDIAN
98 # define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d)
99 # elif _BYTE_ORDER == _LITTLE_ENDIAN
100 # define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24))
101 # else
102 # error "unsupported byte order!"
103 # endif
104 #elif defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) && defined(__BYTE_ORDER)
105 # if __BYTE_ORDER == __BIG_ENDIAN
106 # define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d)
107 # elif __BYTE_ORDER == __LITTLE_ENDIAN
108 # define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24))
109 # else
110 # error "unsupported byte order!"
111 # endif
112 #elif defined(__BIG_ENDIAN__)
113 # define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d)
114 #else // fall back to assuming little-endian
115 # define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24))
90 #endif 116 #endif
91 117
92 const struct { 118 const struct {
93 uint32_t tag; 119 uint32_t tag;
94 bool (*parse)(ots::OpenTypeFile *otf, const uint8_t *data, size_t length); 120 bool (*parse)(ots::OpenTypeFile *otf, const uint8_t *data, size_t length);
95 bool (*serialise)(ots::OTSStream *out, ots::OpenTypeFile *file); 121 bool (*serialise)(ots::OTSStream *out, ots::OpenTypeFile *file);
96 bool (*should_serialise)(ots::OpenTypeFile *file); 122 bool (*should_serialise)(ots::OpenTypeFile *file);
97 void (*free)(ots::OpenTypeFile *file); 123 void (*free)(ots::OpenTypeFile *file);
98 bool required; 124 bool required;
99 } table_parsers[] = { 125 } table_parsers[] = {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 va_start(va, format); 741 va_start(va, format);
716 std::vfprintf(stderr, format, va); 742 std::vfprintf(stderr, format, va);
717 va_end(va); 743 va_end(va);
718 std::fprintf(stderr, "\n"); 744 std::fprintf(stderr, "\n");
719 std::fflush(stderr); 745 std::fflush(stderr);
720 } 746 }
721 } 747 }
722 #endif 748 #endif
723 749
724 } // namespace ots 750 } // namespace ots
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698