gfxstream: modify libaemu for Mesa use case

- Modifications to directory paths.
- saveStringArray moved to Stream.h/Stream.cpp to avoid
  importing StreamSerializing
- C++ include guards
- Namespace changes

find ./ -type f -exec sed -i -e 's/namespace android/namespace gfxstream/g' {} \;

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32062>
This commit is contained in:
Gurchetan Singh 2024-11-05 09:29:13 -08:00 committed by Marge Bot
parent 43e378c537
commit a8c1021d79
7 changed files with 39 additions and 24 deletions

View file

@ -3,13 +3,13 @@
* SPDX-License-Identifier: MIT
*/
#include "aemu/base/files/Stream.h"
#include "Stream.h"
#include <assert.h>
#include <string.h>
namespace android {
namespace base {
namespace gfxstream {
namespace aemu {
void Stream::putByte(uint8_t value) { write(&value, 1U); }
@ -208,5 +208,12 @@ void Stream::fromBe64(uint8_t* v) {
memcpy(v, &value, sizeof(uint64_t));
}
} // namespace base
} // namespace android
void saveStringArray(Stream* stream, const char* const* strings, uint32_t count) {
stream->putBe32(count);
for (uint32_t i = 0; i < count; ++i) {
stream->putString(strings[i]);
}
}
} // namespace aemu
} // namespace gfxstream

View file

@ -19,7 +19,7 @@
#include <malloc.h>
#endif
namespace android {
namespace gfxstream {
/**
* Do not abuse this by using any complicated T. Use it for POD or primitives
@ -147,4 +147,4 @@ class AlignedBuf {
void* aligned_buf_alloc(size_t align, size_t size);
void aligned_buf_free(void* buf);
} // namespace android
} // namespace gfxstream

View file

@ -8,8 +8,8 @@
#include <stddef.h>
#include <string.h>
namespace android {
namespace base {
namespace gfxstream {
namespace aemu {
// A generic memory allocator interface which could be used to allocate
// a certain size of memory region, or memory region for arrays / strings.
@ -55,5 +55,5 @@ class Allocator {
}
};
} // namespace base
} // namespace android
} // namespace aemu
} // namespace gfxstream

View file

@ -9,11 +9,11 @@
#include <unordered_set>
#include <vector>
#include "aemu/base/AlignedBuf.h"
#include "aemu/base/Allocator.h"
#include "AlignedBuf.h"
#include "Allocator.h"
namespace android {
namespace base {
namespace gfxstream {
namespace aemu {
// Class to make it easier to set up memory regions where it is fast
// to allocate buffers AND we don't care about freeing individual pieces,
@ -65,5 +65,5 @@ class BumpPool : public Allocator {
bool mNeedRealloc = false;
};
} // namespace base
} // namespace android
} // namespace aemu
} // namespace gfxstream

View file

@ -10,10 +10,8 @@
#include <string>
#include "aemu/base/msvc.h"
namespace android {
namespace base {
namespace gfxstream {
namespace aemu {
// Abstract interface to byte streams of all kind.
// This is mainly used to implement disk serialization.
@ -109,5 +107,7 @@ class Stream {
static void fromBe64(uint8_t*);
};
} // namespace base
} // namespace android
void saveStringArray(Stream* stream, const char* const* strings, uint32_t count);
} // namespace aemu
} // namespace gfxstream

View file

@ -4,6 +4,10 @@
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
@ -169,3 +173,7 @@ void ring_buffer_consumer_hung_up(struct ring_buffer* r);
// Convenient function to reschedule thread
void ring_buffer_yield();
#ifdef __cplusplus
}
#endif

View file

@ -2,7 +2,7 @@
* Copyright 2018 Google
* SPDX-License-Identifier: MIT
*/
#include "aemu/base/ring_buffer.h"
#include "ring_buffer.h"
#include <errno.h>
#include <string.h>