Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further fix for OPC C64 to build with GCC #2

Merged
merged 2 commits into from Aug 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions software/C64 - OPC5/source/Set.cpp
Expand Up @@ -35,7 +35,7 @@ void CSet::copy(const CSet &s)
{
if (map != dmap) // get rid of an old map
delete[] map;
compl = s.compl;
comp = s.comp;
size = s.size;
nbits = s.nbits;
MemberPtr = s.MemberPtr;
Expand All @@ -52,7 +52,7 @@ CSet& CSet::operator=(CSet &s)
{
if (map != dmap)
delete[] map;
compl = s.compl;
comp = s.comp;
size = s.size;
nbits = s.nbits;
MemberPtr = s.MemberPtr;
Expand Down Expand Up @@ -334,7 +334,7 @@ inline void CSet::clear() // Zero all bits
{ memset((char *)map, 0, size * sizeof(int)); };
inline void CSet::fill() // Set all bits
{ memset((char *)map, ~0, size * sizeof(int)); };
inline void CSet::complement() { compl = ~compl; };
inline void CSet::complement() { comp = ~comp; };

/* --------------------------------------------------------------------
Remove member - clears bit in map
Expand Down Expand Up @@ -588,18 +588,18 @@ void CSet::Serialize(CArchive& ar)
ar << MemberPtr;
ar << nbits;
ar << size;
ar << compl;
ar << comp;
for (nn = 0; nn < size; nn++)
ar << map[nn];
}
else {
ar >> MemberPtr;
ar >> nbits;
ar >> size;
ar >> compl;
ar >> comp;
enlarge(size);
for (nn = 0; nn < size; nn++)
ar >> map[nn];
}
}
*/
*/
13 changes: 13 additions & 0 deletions software/C64 - OPC5/source/compat.h
Expand Up @@ -141,6 +141,19 @@ static inline int strcat_s(
return 0;
}

static inline int _itoa_s(int value, char *buffer, size_t sizeInCharacters, int radix) {
if (radix == 8) {
snprintf(buffer, sizeInCharacters, "%o", value);
} else if (radix == 10) {
snprintf(buffer, sizeInCharacters, "%d", value);
} else if (radix == 16) {
snprintf(buffer, sizeInCharacters, "%x", value);
} else {
return EINVAL;
}
return 0;
}

static inline int sprintf_s(char* buffer, size_t sizeOfBuffer, const char* format, ...)
{
va_list ap;
Expand Down
6 changes: 3 additions & 3 deletions software/C64 - OPC5/source/set.h
Expand Up @@ -28,7 +28,7 @@ class CSet //: public CObject
unsigned __int16 MemberPtr; // for NextMember
unsigned __int16 nbits; // Number of bits in map.
unsigned __int8 size; // number of int's of bitmap.
unsigned __int8 compl; // Negative true set if compl is true
unsigned __int8 comp; // Negative true set if comp is true

void enlarge(int); // increase size of set
int cmp(CSet&) const;
Expand All @@ -40,7 +40,7 @@ class CSet //: public CObject
size = SET_DEFAULT_SIZE;
nbits = SET_DEFAULT_SIZE * sizeof(int) << 3;
MemberPtr = 0;
compl = 0;
comp = 0;
clear();
};
static CSet *MakeNew() {
Expand Down Expand Up @@ -126,7 +126,7 @@ class CSet //: public CObject
int isIntersecting(CSet &s) { return (SetTest(s) == SET_INTER); };
int isEmpty() { return NumMember() == 0; };
int isMember(int bit) { return ((bit >= nbits)||bit < 0 ? 0 : map[bit >> SET_NBIT] & (1 << (bit & SET_BMASK))); }; // is n a member of s ?
int test(int x) { return (isMember(x)) ? !compl : compl; };
int test(int x) { return (isMember(x)) ? !comp : comp; };

// void Serialize(CArchive& ar);
};
Expand Down