From mmlr at mlotz.ch Fri Feb 1 00:04:52 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Fri, 01 Feb 2008 00:04:52 +0100 Subject: [Haiku-commits] =?windows-1252?q?r23800_-_haiku/trunk/src/system/?= =?windows-1252?q?boot/platform/bios=5Fia32?= In-Reply-To: <62F1D364-D69C-4269-A461-4B9DC675726E@foobox.com> Message-ID: <4280628151-BeMail@primary> > Oops, sorry about that one. That SMP code is so ancient I don't even > remember writing it. Most of the structure was cribbed directly from > openblt, which newos shares a tiny bit of ancestry from. I barely > knew > what I was doing back then. :) Well in that case it works surprisingly well ;-) Well I don't think that this would have happened on real hardware anyway. The trampoline code is just too straight forward for the other CPU being too slow. I'm just still trying to get a full 4 CPU system going inside QEMU emulation to find more of those hidden > 2 CPUs SMP issues. Right now it pretty much always stops somewhere in the bootscript. Sometimes there are IDE timeouts reported each few seconds after entering the bootscript. We'll see what is available earlier - emulation of a full 4 CPU system or a kernel debugger with working USB input so I can test it on my real hardware... Regards Michael From mmu_man at mail.berlios.de Fri Feb 1 04:15:41 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 1 Feb 2008 04:15:41 +0100 Subject: [Haiku-commits] r23802 - haiku/trunk/3rdparty/mmu_man/themes Message-ID: <200802010315.m113FfRd029855@sheep.berlios.de> Author: mmu_man Date: 2008-02-01 04:15:40 +0100 (Fri, 01 Feb 2008) New Revision: 23802 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23802&view=rev Modified: haiku/trunk/3rdparty/mmu_man/themes/Jamfile haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.h haiku/trunk/3rdparty/mmu_man/themes/ThemesAddon.h haiku/trunk/3rdparty/mmu_man/themes/UITheme.h Log: Added BeTheme importer. Oops, missing a file :) Modified: haiku/trunk/3rdparty/mmu_man/themes/Jamfile =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/Jamfile 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/Jamfile 2008-02-01 03:15:40 UTC (rev 23802) @@ -26,6 +26,7 @@ ; Application <3rdparty>Themes : + BeThemeImporter.cpp CompareMessages.cpp DumpMessage.cpp MakeScreenshot.cpp @@ -33,6 +34,7 @@ TextInputAlert.cpp ThemeAddonItem.cpp ThemesApp.cpp + ThemeImporter.cpp ThemeInterfaceView.cpp ThemeItem.cpp ThemeManager.cpp Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp 2008-02-01 03:15:40 UTC (rev 23802) @@ -494,6 +494,7 @@ { status_t err; int32 i, count; + int32 importer; BString name; ThemeItem *ti; bool isro; @@ -502,9 +503,12 @@ tman->LoadThemes(); count = tman->CountThemes(); + LockLooper(); fThemeList->MakeEmpty(); UnlockLooper(); + + // native themes for (i = 0; i < count; i++) { err = tman->ThemeName(i, name); isro = tman->ThemeIsReadOnly(i); @@ -516,6 +520,36 @@ UnlockLooper(); } + // for each importer + for (importer = 0; importer < tman->CountThemeImporters(); importer++) { + err = tman->ImportThemesFor(importer); + if (err < 0) + continue; + PRINT(("Imports for %s: %d\n", tman->ThemeImporterAt(importer), (tman->CountThemes() - count))); + if (tman->CountThemes() == count) + continue; // nothing found + // separator item + name = "Imported ("; + name << tman->ThemeImporterAt(importer) << ")"; + BStringItem *si = new BStringItem(name.String()); + si->SetEnabled(false); + LockLooper(); + fThemeList->AddItem(si); + UnlockLooper(); + // add new themes + count = tman->CountThemes(); + for (; i < count; i++) { + err = tman->ThemeName(i, name); + isro = true;//tman->ThemeIsReadOnly(i); + if (err) + continue; + ti = new ThemeItem(i, name.String(), isro); + LockLooper(); + fThemeList->AddItem(ti); + UnlockLooper(); + } + } + // enable controls again BControl *c; LockLooper(); for (i = 0; ChildAt(i); i++) { Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp 2008-02-01 03:15:40 UTC (rev 23802) @@ -21,9 +21,11 @@ #include #include +#include "UITheme.h" #include "ThemeManager.h" #include "ThemesAddon.h" -#include "UITheme.h" +#include "ThemeImporter.h" +#include "BeThemeImporter.h" #include "ParseMessage.h" #include "DumpMessage.h" @@ -54,6 +56,8 @@ AddNames(fNames); LoadSettings(); + // XXX: add more + fThemeImporters.AddItem(new BeThemeImporter()); // XXX test /* @@ -952,6 +956,48 @@ return err; } +int32 ThemeManager::CountThemeImporters() +{ + FENTRY; + return fThemeImporters.CountItems(); +} + +const char * ThemeManager::ThemeImporterAt(int32 index) +{ + FENTRY; + ThemeImporter *importer; + importer = static_cast(fThemeImporters.ItemAt(index)); + if (!importer) + return NULL; + return importer->Name(); +} + +status_t ThemeManager::ImportThemesFor(int32 index, const char *path) +{ + FENTRY; + status_t err; + int32 count; + BString m; + int32 i; + ThemeImporter *importer; + BMessage msg; + BMessage *theme; + + importer = static_cast(fThemeImporters.ItemAt(index)); + if (!importer) + return ENOENT; + + err = importer->FetchThemes(); + if (err < 0) + return err; + while ((importer->ImportNextTheme(&theme)) >= 0) { + AddTheme(theme); + } + importer->EndImports(); + + return B_OK; +} + bool ThemeManager::ThemeHasInfoFor(int32 id, BString &module) { FENTRY; @@ -1025,10 +1071,18 @@ FENTRY; status_t err; BString s; + BMessage *theme; if (id < 0) return true; + theme = (BMessage *)fThemeList.ItemAt(id); + if (!theme) + return true; + // imported themes are always RO for now + if (theme->FindString(Z_THEME_IMPORTER, &s) >= B_OK) + return true; + err = ThemeLocation(id, s); if (err) return true; Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.h 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.h 2008-02-01 03:15:40 UTC (rev 23802) @@ -91,6 +91,11 @@ /* load from disk (zip / folder) */ status_t LoadTheme(const char *path, BMessage **to=NULL); + /* Theme importation */ +int32 CountThemeImporters(); +const char *ThemeImporterAt(int32 index); +status_t ImportThemesFor(int32 index, const char *path=NULL); + /* Theme properties */ bool ThemeHasInfoFor(int32 id, BString &module); @@ -123,6 +128,7 @@ int32 fAddonCount; BList fThemeList; BMessage fNames; /* pretty names for fields */ + BList fThemeImporters; }; } // ns ThemeManager Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemesAddon.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemesAddon.h 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemesAddon.h 2008-02-01 03:15:40 UTC (rev 23802) @@ -1,3 +1,5 @@ +#ifndef _THEMES_ADDON_H +#define _THEMES_ADDON_H /* * ThemesAddon class header */ @@ -95,3 +97,4 @@ using namespace Z::ThemeManager; +#endif /* _THEMES_ADDON_H */ Modified: haiku/trunk/3rdparty/mmu_man/themes/UITheme.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/UITheme.h 2008-01-31 22:49:11 UTC (rev 23801) +++ haiku/trunk/3rdparty/mmu_man/themes/UITheme.h 2008-02-01 03:15:40 UTC (rev 23802) @@ -13,6 +13,8 @@ #define Z_THEME_LOCATION "z:theme:location" // identifies a module this theme has info for. #define Z_THEME_MODULE_TAG "z:theme:moduletag" + // if the theme is imported, where from +#define Z_THEME_IMPORTER "z:theme:importer" // the names of the global BMessages #define Z_THEME_INFO_MESSAGE "z:theme:infos" From mmu_man at mail.berlios.de Fri Feb 1 04:16:20 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 1 Feb 2008 04:16:20 +0100 Subject: [Haiku-commits] r23803 - haiku/trunk/3rdparty/mmu_man/themes Message-ID: <200802010316.m113GKpp029924@sheep.berlios.de> Author: mmu_man Date: 2008-02-01 04:16:18 +0100 (Fri, 01 Feb 2008) New Revision: 23803 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23803&view=rev Added: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.cpp haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h Log: Missing files for BeTheme importer. Added: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:15:40 UTC (rev 23802) +++ haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:16:18 UTC (rev 23803) @@ -0,0 +1,242 @@ +/* + * BeThemeImporter class + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "UITheme.h" +#include "Utils.h" +#include "BeThemeImporter.h" + + +#define DEBUG_BTI +#ifdef DEBUG_BTI +#define FENTRY PRINT(("BeThemeImporter[%s]::%s()\n", Name(), __FUNCTION__)) +#else +#define FENTRY +#endif + +#define QSTR "(name==\"TrackerTheme\")" + +static const deskbar_location kDeskbarLocationMap[] = { + //2:top 1:topright 5:bottom + B_DESKBAR_LEFT_TOP, B_DESKBAR_RIGHT_TOP, B_DESKBAR_TOP, + B_DESKBAR_LEFT_BOTTOM, B_DESKBAR_RIGHT_BOTTOM, B_DESKBAR_BOTTOM +}; + +BeThemeImporter::BeThemeImporter() + :ThemeImporter("BeTheme") +{ + FENTRY; + BVolumeRoster r; + BVolume v; + r.GetBootVolume(&v); + fQuery.Clear(); + fQuery.SetVolume(&v); + fQuery.SetPredicate(QSTR); +} + +BeThemeImporter::~BeThemeImporter() +{ + FENTRY; + fQuery.Clear(); +} + +const char *BeThemeImporter::Description() +{ + FENTRY; + return "Imports BeTheme themes"; +} + +status_t BeThemeImporter::FetchThemes() +{ + FENTRY; + return fQuery.Fetch(); +} + +status_t BeThemeImporter::ImportNextTheme(BMessage **theme) +{ + FENTRY; + status_t err; + BEntry ent; + int i, j; + + err = fQuery.GetNextEntry(&ent); + if (err < B_OK) + return err; + BDirectory dir; + BDirectory settingsDir; + BPath path; + err = ent.GetParent(&dir); + ent.GetParent(&ent); + ent.GetPath(&path); + if (err < 0) + return err; + err = settingsDir.SetTo(&dir, "Settings"); + if (err < 0) + return err; + PRINT(("BeThemeImporter: importing from '%s'\n", path.Path())); + + BMessage global(Z_THEME_MESSAGE_WHAT); + BMessage info; + BMessage decor; + BMessage backgrounds; + BMessage deskbar; + info.AddString(Z_THEME_NAME, path.Leaf()); + global.AddString(Z_THEME_LOCATION, path.Path()); + + BFile file; + int32 value; + int64 llvalue; + int32 first; + + err = file.SetTo(&settingsDir, "Description", B_READ_ONLY); + if (err < B_OK) + return err; + BString str; + char *buff; + buff = str.LockBuffer(1024); + memset(buff, 0, 1024); + file.Read(buff, 1024); + if (err < B_OK) + return err; + str.UnlockBuffer(); + info.AddString(Z_THEME_DESCRIPTION, str.String()); + info.AddString(Z_THEME_SCREENSHOT_FILENAME, "Settings/Preview.jpg"); + + + err = file.SetTo(&settingsDir, "Deskbar", B_READ_ONLY); + if (err < B_OK) + return err; + str = ""; + buff = str.LockBuffer(1024); + memset(buff, 0, 1024); + file.Read(buff, 1024); + if (err < B_OK) + return err; + str.UnlockBuffer(); + str.ReplaceSet("\r\n", " "); + for (i = 0; str.Length() > 0; i++) { + BString token; + first = str.FindFirst(' '); + first = first < 0 ? str.Length() : first + 1; + str.MoveInto(token, 0, first); + if (token.Length() < 2) + continue; + if (sscanf(token.String(), "POS:%ld", &value) >= 1) { + value = (value < 6) ? kDeskbarLocationMap[value] : B_DESKBAR_RIGHT_TOP; + deskbar.AddInt32("db:location", value); + } + if (sscanf(token.String(), "EXP:%ld", &value) >= 1) { + deskbar.AddBool("db:expanded", value != 0); + } + if (sscanf(token.String(), "DECOR:%ld", &value) >= 1) { + value = (value < 4) ? value : 0; + decor.AddInt32("window:R5:decor", value); + } + } + + err = file.SetTo(&settingsDir, "WorkSpaces", B_READ_ONLY); + if (err < B_OK) + return err; + buff = str.LockBuffer(1024); + memset(buff, 0, 1024); + file.Read(buff, 1024); + if (err < B_OK) + return err; + str.UnlockBuffer(); + BString line; + for (i = 0; str.Length() > 0; i++) { + first = str.FindFirst('\n'); + first = first < 0 ? str.Length() : first + 1; + str.MoveInto(line, 0, first); + if (line.Length() < 2) + break; + + rgb_color color; + bool erasetext = false; + int32 mode = B_BACKGROUND_MODE_SCALED; + //int32 set = 0; // ? + BPoint offset; + uint32 workspaces = 0; + + for (j = 0; line.Length() > 0; j++) { + BString token; + first = line.FindFirst(' '); + first = first < 0 ? line.Length() : first + 1; + line.MoveInto(token, 0, first); + if (token.Length() < 2) + break; + + if (sscanf(token.String(), "R:%ld", &value) >= 1) { + color.red = (int8) value; + } + if (sscanf(token.String(), "G:%ld", &value) >= 1) { + color.green = (int8) value; + } + if (sscanf(token.String(), "B:%ld", &value) >= 1) { + color.blue = (int8) value; + } + color.alpha = 255; + if (sscanf(token.String(), "BGM:%ld", &value) >= 1) { + mode = value; + } + if (sscanf(token.String(), "ERASETEXT:%ld", &value) >= 1) { + erasetext = value != 0; + } + if (sscanf(token.String(), "x:%ld", &value) >= 1) { + offset.x = value; + } + if (sscanf(token.String(), "y:%ld", &value) >= 1) { + offset.y = value; + } + + if (sscanf(token.String(), "WORKSPACE:%Lx", &llvalue) >= 1) { + workspaces = (uint32)llvalue; + } + + } + + BString image(path.Path()); + image << "/Settings/"; + image << "Background" << i << ".jpg"; + + backgrounds.AddString(B_BACKGROUND_IMAGE, image.String()); + backgrounds.AddInt32(B_BACKGROUND_MODE, mode); + backgrounds.AddPoint(B_BACKGROUND_ORIGIN, offset); + backgrounds.AddBool(B_BACKGROUND_ERASE_TEXT, erasetext); + backgrounds.AddInt32(B_BACKGROUND_WORKSPACES, workspaces); + AddRGBColor(backgrounds, "be:desktop_color", color); + } + + + global.AddMessage(Z_THEME_INFO_MESSAGE, &info); + global.AddMessage(Z_THEME_WINDOW_DECORATIONS, &decor); + global.AddMessage(Z_THEME_BACKGROUND_SETTINGS, &backgrounds); + global.AddMessage(Z_THEME_DESKBAR_SETTINGS, &deskbar); + *theme = new BMessage(global); + //global.PrintToStream(); + + return B_OK; +} + +status_t BeThemeImporter::EndImports() +{ + FENTRY; + fQuery.Clear(); + return B_OK; +} + Added: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h 2008-02-01 03:15:40 UTC (rev 23802) +++ haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h 2008-02-01 03:16:18 UTC (rev 23803) @@ -0,0 +1,42 @@ +#ifndef _BE_THEME_IMPORTER_H +#define _BE_THEME_IMPORTER_H +/* + * BeTheme Importer class header + */ + +#include + +#include "ThemeImporter.h" + +namespace Z { +namespace ThemeManager { + +class BeThemeImporter : public ThemeImporter { +public: + BeThemeImporter(); +virtual ~BeThemeImporter(); + + /* presentation */ + +virtual const char *Description(); /* tooltip... */ + + /* Theme manipulation */ + +virtual status_t FetchThemes(); +virtual status_t ImportNextTheme(BMessage **theme); +virtual status_t EndImports(); + + /* */ + +private: + +friend class Z::ThemeManager::ThemeManager; + BQuery fQuery; +}; + +} // ns ThemeManager +} // ns Z + +using namespace Z::ThemeManager; + +#endif /* _BE_THEME_IMPORTER_H */ \ No newline at end of file Added: haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.cpp 2008-02-01 03:15:40 UTC (rev 23802) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.cpp 2008-02-01 03:16:18 UTC (rev 23803) @@ -0,0 +1,95 @@ +/* + * ThemeImporter class + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "ThemeImporter.h" + + +#define DEBUG_TI +#ifdef DEBUG_TI +#define FENTRY PRINT(("ThemesImporter[%s]::%s()\n", Name(), __FUNCTION__)) +#else +#define FENTRY +#endif + + +ThemeImporter::ThemeImporter(const char *name) + :fName(name), + fFlags(0L) +{ + FENTRY; + fSettings.MakeEmpty(); +} + +ThemeImporter::~ThemeImporter() +{ + FENTRY; +} + +const char *ThemeImporter::Name() +{ + return fName.String(); +} + +const char *ThemeImporter::Description() +{ + FENTRY; + return "No description yet."; +} + +status_t ThemeImporter::LoadSettings(BMessage &settings) +{ + FENTRY; + uint32 flags; + fSettings = settings; + if (fSettings.FindInt32("ta:flags", (int32 *)&flags) >= B_OK) + fFlags = flags; + return B_OK; +} + +status_t ThemeImporter::SaveSettings(BMessage &settings) +{ + FENTRY; + status_t err; + err = fSettings.ReplaceInt32("ta:flags", fFlags); + settings = fSettings; + return err; +} + +void ThemeImporter::SetFlags(uint32 flags) +{ + fFlags = flags; +} + +uint32 ThemeImporter::Flags() +{ + return fFlags; +} + +status_t ThemeImporter::FetchThemes() +{ + FENTRY; + return B_OK; +} + +status_t ThemeImporter::ImportNextTheme(BMessage **theme) +{ + FENTRY; + return ENOENT; +} + +status_t ThemeImporter::EndImports() +{ + FENTRY; + return B_OK; +} + Added: haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h 2008-02-01 03:15:40 UTC (rev 23802) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h 2008-02-01 03:16:18 UTC (rev 23803) @@ -0,0 +1,53 @@ +#ifndef _THEME_IMPORTER_H +#define _THEME_IMPORTER_H +/* + * ThemeImporter class header + */ + +class BDirectory; +class BMessage; +class BString; + +namespace Z { +namespace ThemeManager { + +class ThemeManager; + +class ThemeImporter { +public: + ThemeImporter(const char *name); +virtual ~ThemeImporter(); + + /* presentation */ + +virtual const char *Name(); /* pretty name */ +virtual const char *Description(); /* tooltip... */ + // if you override, call it first +virtual status_t LoadSettings(BMessage &settings); + // if you override, call it last +virtual status_t SaveSettings(BMessage &settings); +void SetFlags(uint32 flags); +uint32 Flags(); + + /* Theme manipulation */ + +virtual status_t FetchThemes(); +virtual status_t ImportNextTheme(BMessage **theme); +virtual status_t EndImports(); + + /* */ + +protected: + +friend class Z::ThemeManager::ThemeManager; + BString fName; + uint32 fFlags; + BMessage fSettings; +}; + +} // ns ThemeManager +} // ns Z + +using namespace Z::ThemeManager; + +#endif /* _THEME_IMPORTER_H */ \ No newline at end of file From mmu_man at mail.berlios.de Fri Feb 1 04:27:10 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 1 Feb 2008 04:27:10 +0100 Subject: [Haiku-commits] r23804 - haiku/trunk/3rdparty/mmu_man/themes Message-ID: <200802010327.m113RAGC030656@sheep.berlios.de> Author: mmu_man Date: 2008-02-01 04:27:09 +0100 (Fri, 01 Feb 2008) New Revision: 23804 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23804&view=rev Modified: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp Log: Fix Haiku build and warnings. Modified: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:16:18 UTC (rev 23803) +++ haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:27:09 UTC (rev 23804) @@ -22,9 +22,9 @@ #include "BeThemeImporter.h" -#define DEBUG_BTI -#ifdef DEBUG_BTI -#define FENTRY PRINT(("BeThemeImporter[%s]::%s()\n", Name(), __FUNCTION__)) +#define DEBUG_TI +#ifdef DEBUG_TI +#define FENTRY PRINT(("ThemeImporter[%s]::%s()\n", Name(), __FUNCTION__)) #else #define FENTRY #endif Modified: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h 2008-02-01 03:16:18 UTC (rev 23803) +++ haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.h 2008-02-01 03:27:09 UTC (rev 23804) @@ -39,4 +39,4 @@ using namespace Z::ThemeManager; -#endif /* _BE_THEME_IMPORTER_H */ \ No newline at end of file +#endif /* _BE_THEME_IMPORTER_H */ Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h 2008-02-01 03:16:18 UTC (rev 23803) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeImporter.h 2008-02-01 03:27:09 UTC (rev 23804) @@ -50,4 +50,4 @@ using namespace Z::ThemeManager; -#endif /* _THEME_IMPORTER_H */ \ No newline at end of file +#endif /* _THEME_IMPORTER_H */ Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp 2008-02-01 03:16:18 UTC (rev 23803) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp 2008-02-01 03:27:09 UTC (rev 23804) @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include From mmu_man at mail.berlios.de Fri Feb 1 04:54:02 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 1 Feb 2008 04:54:02 +0100 Subject: [Haiku-commits] r23805 - haiku/trunk/3rdparty/mmu_man/themes Message-ID: <200802010354.m113s2QC000424@sheep.berlios.de> Author: mmu_man Date: 2008-02-01 04:54:01 +0100 (Fri, 01 Feb 2008) New Revision: 23805 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23805&view=rev Modified: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp Log: Only quit the loop on ENOENT to try and load next themes. Modified: haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:27:09 UTC (rev 23804) +++ haiku/trunk/3rdparty/mmu_man/themes/BeThemeImporter.cpp 2008-02-01 03:54:01 UTC (rev 23805) @@ -87,7 +87,7 @@ return err; err = settingsDir.SetTo(&dir, "Settings"); if (err < 0) - return err; + return B_ERROR; PRINT(("BeThemeImporter: importing from '%s'\n", path.Path())); BMessage global(Z_THEME_MESSAGE_WHAT); @@ -105,7 +105,7 @@ err = file.SetTo(&settingsDir, "Description", B_READ_ONLY); if (err < B_OK) - return err; + return B_ERROR; BString str; char *buff; buff = str.LockBuffer(1024); @@ -120,7 +120,7 @@ err = file.SetTo(&settingsDir, "Deskbar", B_READ_ONLY); if (err < B_OK) - return err; + return B_ERROR; str = ""; buff = str.LockBuffer(1024); memset(buff, 0, 1024); @@ -151,7 +151,7 @@ err = file.SetTo(&settingsDir, "WorkSpaces", B_READ_ONLY); if (err < B_OK) - return err; + return B_ERROR; buff = str.LockBuffer(1024); memset(buff, 0, 1024); file.Read(buff, 1024); Modified: haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp =================================================================== --- haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp 2008-02-01 03:27:09 UTC (rev 23804) +++ haiku/trunk/3rdparty/mmu_man/themes/ThemeManager.cpp 2008-02-01 03:54:01 UTC (rev 23805) @@ -990,8 +990,9 @@ err = importer->FetchThemes(); if (err < 0) return err; - while ((importer->ImportNextTheme(&theme)) >= 0) { - AddTheme(theme); + while ((err = importer->ImportNextTheme(&theme)) != ENOENT) { + if (err >= 0) + AddTheme(theme); } importer->EndImports(); From axeld at pinc-software.de Fri Feb 1 10:19:32 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 01 Feb 2008 10:19:32 +0100 CET Subject: [Haiku-commits] r23796 - in haiku/trunk: headers/private/graphics In-Reply-To: <25249417.1201808545114.JavaMail.ngmail@webmail18> Message-ID: <6292228226-BeMail@zon> Marcus Overhagen wrote: > axeld at BerliOS wrote: > > +get_area_base_and_size(area_id area, addr_t base, size_t size) > > +{ > [...] > > + base = (addr_t)info.address; > > + size = info.size; > > + return B_OK; > > +} > Ever heard of pointers? ;-) Sure, I'm just too stupid to use them. Or reference parameters, for that matter ;-) Bye, Axel. From bonefish at mail.berlios.de Fri Feb 1 13:11:04 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 13:11:04 +0100 Subject: [Haiku-commits] r23806 - haiku/trunk/src/system/kernel Message-ID: <200802011211.m11CB4Ys016746@sheep.berlios.de> Author: bonefish Date: 2008-02-01 13:11:02 +0100 (Fri, 01 Feb 2008) New Revision: 23806 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23806&view=rev Modified: haiku/trunk/src/system/kernel/elf.cpp Log: Clarifying comment. Modified: haiku/trunk/src/system/kernel/elf.cpp =================================================================== --- haiku/trunk/src/system/kernel/elf.cpp 2008-02-01 03:54:01 UTC (rev 23805) +++ haiku/trunk/src/system/kernel/elf.cpp 2008-02-01 12:11:02 UTC (rev 23806) @@ -1235,6 +1235,9 @@ } +/*! Tries to find a matching user symbol for the given address. + Note that the given team's address must already be in effect. +*/ status_t elf_debug_lookup_user_symbol_address(struct team* team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, From bonefish at mail.berlios.de Fri Feb 1 13:15:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 13:15:01 +0100 Subject: [Haiku-commits] r23807 - haiku/trunk/src/system/kernel Message-ID: <200802011215.m11CF1RA018938@sheep.berlios.de> Author: bonefish Date: 2008-02-01 13:15:00 +0100 (Fri, 01 Feb 2008) New Revision: 23807 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23807&view=rev Modified: haiku/trunk/src/system/kernel/syscalls.cpp Log: Syscall tracing no longer fetches the string parameter of the _kern_ktrace_output() syscall, since it will be stored in a separate entry anyway. Modified: haiku/trunk/src/system/kernel/syscalls.cpp =================================================================== --- haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-01 12:11:02 UTC (rev 23806) +++ haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-01 12:15:00 UTC (rev 23807) @@ -38,7 +38,9 @@ #include #include +#include "syscall_numbers.h" + typedef struct generic_syscall generic_syscall; struct generic_syscall { @@ -324,7 +326,7 @@ kSyscallInfos[syscall].parameter_size, false); // copy string parameters, if any - if (fParameters != NULL) { + if (fParameters != NULL && syscall != SYSCALL_KTRACE_OUTPUT) { int32 stringIndex = 0; const extended_syscall_info& syscallInfo = kExtendedSyscallInfos[fSyscall]; @@ -379,7 +381,8 @@ value = (uint64)*(void**)data; break; case B_STRING_TYPE: - if (stringIndex < MAX_PARAM_STRINGS) { + if (stringIndex < MAX_PARAM_STRINGS + && fSyscall != SYSCALL_KTRACE_OUTPUT) { out.Print("%s\"%s\"", (i == 0 ? "" : ", "), fParameterStrings[stringIndex++]); From bonefish at mail.berlios.de Fri Feb 1 13:21:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 13:21:42 +0100 Subject: [Haiku-commits] r23808 - haiku/trunk/src/system/kernel/debug Message-ID: <200802011221.m11CLgRB028469@sheep.berlios.de> Author: bonefish Date: 2008-02-01 13:21:41 +0100 (Fri, 01 Feb 2008) New Revision: 23808 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23808&view=rev Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp Log: Renamed "printteam" switch for "traced" command to "--printteam". Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-01 12:15:00 UTC (rev 23807) +++ haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-01 12:21:41 UTC (rev 23808) @@ -716,7 +716,7 @@ AbstractTraceEntry::sPrintTeamID = false; if (argi < argc) { - if (strcmp(argv[argi], "printteam") == 0) { + if (strcmp(argv[argi], "--printteam") == 0) { AbstractTraceEntry::sPrintTeamID = true; argi++; } @@ -1012,7 +1012,7 @@ add_debugger_command_etc("traced", &dump_tracing, "Dump recorded trace entries", - "[ \"printteam\" ] (\"forward\" | \"backward\") " + "[ \"--printteam\" ] (\"forward\" | \"backward\") " "| ([ [ [ ] ] ] " "[ # | (\"filter\" ) ])\n" "Prints recorded trace entries. If \"backward\" or \"forward\" is\n" @@ -1022,7 +1022,7 @@ "afterwards entering an empty line in the debugger will reinvoke it.\n" "If no arguments are given, the command continues in the direction\n" "of the last invocation.\n" - "\"printteam\" enables printing the items' team ID.\n" + "\"--printteam\" enables printing the items' team ID.\n" " - The base index of the entries to print. Depending on\n" " whether the iteration direction is forward or\n" " backward this will be the first or last entry printed\n" From bonefish at mail.berlios.de Fri Feb 1 13:23:28 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 13:23:28 +0100 Subject: [Haiku-commits] r23809 - haiku/trunk/src/system/kernel Message-ID: <200802011223.m11CNS1V001150@sheep.berlios.de> Author: bonefish Date: 2008-02-01 13:23:28 +0100 (Fri, 01 Feb 2008) New Revision: 23809 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23809&view=rev Modified: haiku/trunk/src/system/kernel/Jamfile Log: syscalls.cpp also includes syscall_numbers.h, now. Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-02-01 12:21:41 UTC (rev 23808) +++ haiku/trunk/src/system/kernel/Jamfile 2008-02-01 12:23:28 UTC (rev 23809) @@ -49,7 +49,9 @@ # We need to specify the dependency on the generated syscalls files explicitly. Includes [ FGristFiles syscalls.cpp ] - : syscall_dispatcher.h syscall_table.h ; + : syscall_dispatcher.h syscall_table.h + syscall_numbers.h +; KernelLd linkhack.so : <$(SOURCE_GRIST)>linkhack.o From bonefish at mail.berlios.de Fri Feb 1 13:35:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 13:35:01 +0100 Subject: [Haiku-commits] r23810 - in haiku/trunk: headers/private/kernel src/kits/app Message-ID: <200802011235.m11CZ1Ks020050@sheep.berlios.de> Author: bonefish Date: 2008-02-01 13:35:00 +0100 (Fri, 01 Feb 2008) New Revision: 23810 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23810&view=rev Modified: haiku/trunk/headers/private/kernel/tracing_config.h haiku/trunk/src/kits/app/Message.cpp Log: Added optional kernel tracing for sending BMessages. Currently only the destination of the message and it's "what" field are stored. It might be nice to also get some info about its fields -- maybe as an additional option. Modified: haiku/trunk/headers/private/kernel/tracing_config.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-01 12:23:28 UTC (rev 23809) +++ haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-01 12:35:00 UTC (rev 23810) @@ -10,7 +10,7 @@ // tracing buffer size (in bytes) #ifndef MAX_TRACE_SIZE -# define MAX_TRACE_SIZE 1024 * 1024 +# define MAX_TRACE_SIZE (1024 * 1024) #endif @@ -20,5 +20,6 @@ //#define SIGNAL_TRACING //#define SYSCALL_TRACING //#define TEAM_TRACING +//#define BMESSAGE_TRACING #endif // KERNEL_TRACING_CONFIG_H Modified: haiku/trunk/src/kits/app/Message.cpp =================================================================== --- haiku/trunk/src/kits/app/Message.cpp 2008-02-01 12:23:28 UTC (rev 23809) +++ haiku/trunk/src/kits/app/Message.cpp 2008-02-01 12:35:00 UTC (rev 23810) @@ -32,11 +32,20 @@ #include #include +#include + // kernel tracing configuration #define DEBUG_FUNCTION_ENTER //debug_printf("thread: 0x%x; this: 0x%08x; header: 0x%08x; fields: 0x%08x; data: 0x%08x; line: %04ld; func: %s\n", find_thread(NULL), this, fHeader, fFields, fData, __LINE__, __PRETTY_FUNCTION__); #define DEBUG_FUNCTION_ENTER2 //debug_printf("thread: 0x%x; line: %04ld: func: %s\n", find_thread(NULL), __LINE__, __PRETTY_FUNCTION__); +#ifdef BMESSAGE_TRACING +# define KTRACE(format...) ktrace_printf(format) +#else +# define KTRACE(format...) +#endif + + const char *B_SPECIFIER_ENTRY = "specifiers"; const char *B_PROPERTY_ENTRY = "property"; const char *B_PROPERTY_NAME_ENTRY = "name"; @@ -1911,6 +1920,10 @@ header->flags |= MESSAGE_FLAG_WAS_DELIVERED; if (direct != NULL) { + KTRACE("BMessage send direct: port: %ld, token: %ld, " + "message: '%c%c%c%c'", port, token, + char(what >> 24), char(what >> 16), char(what >> 8), (char)what); + // this is a local message transmission direct->AddMessage(copy); @@ -1921,6 +1934,10 @@ direct->Release(); } else { + KTRACE("BMessage send remote: team: %ld, port: %ld, token: %ld, " + "message: '%c%c%c%c'", portOwner, port, token, + char(what >> 24), char(what >> 16), char(what >> 8), (char)what); + do { result = write_port_etc(port, kPortMessageCode, (void *)buffer, size, B_RELATIVE_TIMEOUT, timeout); From stippi at mail.berlios.de Fri Feb 1 15:50:06 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 1 Feb 2008 15:50:06 +0100 Subject: [Haiku-commits] r23811 - haiku/trunk/src/apps/drivesetup Message-ID: <200802011450.m11Eo63m005468@sheep.berlios.de> Author: stippi Date: 2008-02-01 15:50:06 +0100 (Fri, 01 Feb 2008) New Revision: 23811 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23811&view=rev Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp haiku/trunk/src/apps/drivesetup/DiskView.h haiku/trunk/src/apps/drivesetup/MainWindow.cpp haiku/trunk/src/apps/drivesetup/PartitionList.cpp haiku/trunk/src/apps/drivesetup/PartitionList.h Log: * implemented detecting and displaying available space on devices and partitions - I couldn't test it yet, but what is definitely missing is being able to select these spaces to create new partitions on them * fixed the bug that if you select a partition on another disk, the disk view does not switch to the new disk. (I was comparing disk pointers, but since I deleted the old BDiskDevice instance first, the new one got assigned the same pointer... at least it appears I am not leaking memory anywhere... :-)) Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-01 12:35:00 UTC (rev 23810) +++ haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-01 14:50:06 UTC (rev 23811) @@ -11,6 +11,7 @@ #include #include #include +#include #include using BPrivate::HashMap; @@ -24,10 +25,13 @@ class PartitionView : public BView { public: - PartitionView(const char* name, float weight, int32 level, partition_id id) + PartitionView(const char* name, float weight, off_t offset, + int32 level, partition_id id) : BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE) , fID(id) , fWeight(weight) + , fOffset(offset) + , fLevel(level) , fSelected(false) , fMouseOver(false) , fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset)) @@ -37,7 +41,7 @@ SetViewColor(B_TRANSPARENT_COLOR); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); base = tint_color(base, B_LIGHTEN_2_TINT); - base = tint_color(base, 1 + 0.13 * level); + base = tint_color(base, 1 + 0.13 * (level - 1)); SetLowColor(base); SetHighColor(tint_color(base, B_DARKEN_1_TINT)); @@ -84,11 +88,16 @@ SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); StrokeRect(b, B_SOLID_HIGH); b.InsetBy(1, 1); + StrokeRect(b, B_SOLID_HIGH); + b.InsetBy(1, 1); + } else if (fLevel > 0) { + StrokeRect(b, B_SOLID_HIGH); + b.InsetBy(1, 1); } - StrokeRect(b, B_SOLID_HIGH); - b.InsetBy(1, 1); FillRect(b, B_SOLID_LOW); + + // prevent the text from moving when border width changes if (!fSelected) b.InsetBy(1, 1); @@ -127,6 +136,16 @@ return fWeight; } + off_t Offset() const + { + return fOffset; + } + + int32 Level() const + { + return fLevel; + } + BGroupLayout* GroupLayout() const { return fGroupLayout; @@ -153,6 +172,8 @@ private: partition_id fID; float fWeight; + off_t fOffset; + int32 fLevel; bool fSelected; bool fMouseOver; BGroupLayout* fGroupLayout; @@ -170,20 +191,22 @@ virtual bool Visit(BDiskDevice* device) { - PartitionView* view = new PartitionView("Device", 1.0, 0, device->ID()); + PartitionView* view = new PartitionView("Device", 1.0, + device->Offset(), 0, device->ID()); fViewMap.Put(device->ID(), view); fView->GetLayout()->AddView(view); + _AddSpaces(device, view); return false; } virtual bool Visit(BPartition* partition, int32 level) { - if (!partition->Parent() || !fViewMap.ContainsKey(partition->Parent()->ID())) + if (!partition->Parent() + || !fViewMap.ContainsKey(partition->Parent()->ID())) return false; // calculate size factor within parent frame -// TODO: support gaps view these offsets: -// off_t offset = partition->Offset(); + off_t offset = partition->Offset(); // off_t parentOffset = partition->Parent()->Offset(); off_t size = partition->Size(); off_t parentSize = partition->Parent()->Size(); @@ -197,13 +220,15 @@ name << "Partition " << partition->ID(); } partition_id id = partition->ID(); - PartitionView* view = new PartitionView(name.String(), scale, level, id); + PartitionView* view = new PartitionView(name.String(), scale, offset, + level, id); view->SetSelected(id == fSelectedPartition); PartitionView* parent = fViewMap.Get(partition->Parent()->ID()); BGroupLayout* layout = parent->GroupLayout(); layout->AddView(view, scale); fViewMap.Put(partition->ID(), view); + _AddSpaces(partition, view); return false; } @@ -232,7 +257,36 @@ } private: + void _AddSpaces(BPartition* partition, PartitionView* parentView) const + { + // add any available space on the partition + BPartitioningInfo info; + if (partition->GetPartitioningInfo(&info) >= B_OK) { + off_t parentSize = partition->Size(); + off_t offset; + off_t size; + for (int32 i = 0; + info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK; + i++) { + double scale = (double)size / parentSize; + PartitionView* view = new PartitionView("Empty", scale, + offset, parentView->Level() + 1, -2); + BGroupLayout* layout = parentView->GroupLayout(); + int32 count = parentView->CountChildren(); + int32 insertIndex = 0; + for (int32 j = 0; j < count; j++) { + PartitionView* sibling = dynamic_cast( + parentView->ChildAt(j)); + if (sibling && sibling->Offset() > offset) + break; + insertIndex++; + } + layout->AddView(view, scale); + } + } + } + typedef HashKey32 PartitionKey; typedef HashMap PartitionViewMap; @@ -247,15 +301,15 @@ DiskView::DiskView(const BRect& frame, uint32 resizeMode) : Inherited(frame, "diskview", resizeMode, - B_WILL_DRAW | B_FRAME_EVENTS) + B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) , fDiskCount(0) , fDisk(NULL) , fPartitionLayout(new PartitionLayout(this)) { BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset); - layout->SetInsets(2, 2, 2, 2); SetLayout(layout); + SetViewColor(B_TRANSPARENT_COLOR); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); SetHighColor(tint_color(base, B_DARKEN_2_TINT)); SetLowColor(tint_color(base, (B_DARKEN_2_TINT + B_DARKEN_1_TINT) / 2)); @@ -337,13 +391,6 @@ void -DiskView::FrameResized(float width, float height) -{ -// DoLayout(); -} - - -void DiskView::SetDiskCount(int32 count) { fDiskCount = count; Modified: haiku/trunk/src/apps/drivesetup/DiskView.h =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.h 2008-02-01 12:35:00 UTC (rev 23810) +++ haiku/trunk/src/apps/drivesetup/DiskView.h 2008-02-01 14:50:06 UTC (rev 23811) @@ -19,7 +19,6 @@ // BView interface virtual void Draw(BRect updateRect); - virtual void FrameResized(float width, float height); void SetDiskCount(int32 count); void SetDisk(BDiskDevice* disk, Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-01 12:35:00 UTC (rev 23810) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-01 14:50:06 UTC (rev 23811) @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -49,17 +50,35 @@ virtual bool Visit(BDiskDevice* device) { fDiskCount++; - fPartitionList->AddPartition(device); + _AddPartition(device); return false; // Don't stop yet! } virtual bool Visit(BPartition* partition, int32 level) { - fPartitionList->AddPartition(partition); + _AddPartition(partition); return false; // Don't stop yet! } private: + void _AddPartition(BPartition* partition) const + { + // add the partition itself + fPartitionList->AddPartition(partition); + + // add any available space on it + BPartitioningInfo info; + if (partition->GetPartitioningInfo(&info) >= B_OK) { + off_t offset; + off_t size; + for (int32 i = 0; + info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK; + i++) { + fPartitionList->AddSpace(partition->ID(), offset, size); + } + } + } + PartitionListView* fPartitionList; int32& fDiskCount; }; @@ -402,8 +421,9 @@ void MainWindow::_SetToDiskAndPartition(partition_id disk, partition_id partition) { + BDiskDevice* oldDisk = NULL; if (!fCurrentDisk || fCurrentDisk->ID() != disk) { - delete fCurrentDisk; + oldDisk = fCurrentDisk; fCurrentDisk = NULL; if (disk >= 0) { BDiskDevice* newDisk = new BDiskDevice(); @@ -420,6 +440,8 @@ fDiskView->SetDisk(fCurrentDisk, fCurrentPartitionID); _EnabledDisableMenuItems(fCurrentDisk, fCurrentPartitionID); + + delete oldDisk; } Modified: haiku/trunk/src/apps/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-01 12:35:00 UTC (rev 23810) +++ haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-01 14:50:06 UTC (rev 23811) @@ -28,6 +28,7 @@ PartitionListRow::PartitionListRow(BPartition* partition) : Inherited() , fPartitionID(partition->ID()) + , fParentID(partition->Parent() ? partition->Parent()->ID() : -1) , fOffset(partition->Offset()) , fSize(partition->Size()) { @@ -57,9 +58,11 @@ } -PartitionListRow::PartitionListRow(partition_id id, off_t offset, off_t size) +PartitionListRow::PartitionListRow(partition_id parentID, off_t offset, + off_t size) : Inherited() - , fPartitionID(id) + , fPartitionID(-2) + , fParentID(parentID) , fOffset(offset) , fSize(size) { @@ -156,22 +159,16 @@ PartitionListRow* -PartitionListView::AddSpace(partition_id parentID, partition_id id, - off_t offset, off_t size) +PartitionListView::AddSpace(partition_id parentID, off_t offset, off_t size) { - PartitionListRow* partitionrow = FindRow(id); - - // forget about it if this item is already in the listview - if (partitionrow != NULL) - return partitionrow; - // the parent should already be in the listview PartitionListRow* parent = FindRow(parentID); if (!parent) return NULL; // create the row for this partition - partitionrow = new PartitionListRow(id, offset, size); + PartitionListRow* partitionrow = new PartitionListRow(parentID, + offset, size); // find a proper insertion index based on the on-disk offset int32 index = _InsertIndexForOffset(parent, offset); Modified: haiku/trunk/src/apps/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-01 12:35:00 UTC (rev 23810) +++ haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-01 14:50:06 UTC (rev 23811) @@ -25,7 +25,7 @@ typedef BRow Inherited; public: PartitionListRow(BPartition* partition); - PartitionListRow(partition_id id, + PartitionListRow(partition_id parentID, off_t offset, off_t size); partition_id ID() const @@ -36,6 +36,7 @@ { return fSize; } private: partition_id fPartitionID; + partition_id fParentID; off_t fOffset; off_t fSize; }; @@ -51,7 +52,7 @@ PartitionListRow* parent = NULL); PartitionListRow* AddPartition(BPartition* partition); PartitionListRow* AddSpace(partition_id parent, - partition_id id, off_t offset, off_t size); + off_t offset, off_t size); private: int32 _InsertIndexForOffset(PartitionListRow* parent, From stippi at mail.berlios.de Fri Feb 1 19:02:05 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 1 Feb 2008 19:02:05 +0100 Subject: [Haiku-commits] r23812 - haiku/trunk/src/apps/drivesetup Message-ID: <200802011802.m11I25dG012679@sheep.berlios.de> Author: stippi Date: 2008-02-01 19:02:04 +0100 (Fri, 01 Feb 2008) New Revision: 23812 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23812&view=rev Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp haiku/trunk/src/apps/drivesetup/MainWindow.cpp Log: * To be able to call BPartition::GetPartitioningIngo(), you need to call PrepareModifications() on the parent BDiskDevice first. Hm. I should probably reorganize things a bit. * Selecting these empty spaces is still not supported. * Fixed inserting empty spaces in the DiskView at the correct index. Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-01 14:50:06 UTC (rev 23811) +++ haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-01 18:02:04 UTC (rev 23812) @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -225,7 +226,7 @@ view->SetSelected(id == fSelectedPartition); PartitionView* parent = fViewMap.Get(partition->Parent()->ID()); BGroupLayout* layout = parent->GroupLayout(); - layout->AddView(view, scale); + layout->AddView(_FindInsertIndex(view, layout), view, scale); fViewMap.Put(partition->ID(), view); _AddSpaces(partition, view); @@ -269,23 +270,30 @@ info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK; i++) { double scale = (double)size / parentSize; - PartitionView* view = new PartitionView("Empty", scale, + PartitionView* view = new PartitionView("", scale, offset, parentView->Level() + 1, -2); BGroupLayout* layout = parentView->GroupLayout(); - int32 count = parentView->CountChildren(); - int32 insertIndex = 0; - for (int32 j = 0; j < count; j++) { - PartitionView* sibling = dynamic_cast( - parentView->ChildAt(j)); - if (sibling && sibling->Offset() > offset) - break; - insertIndex++; - } - layout->AddView(view, scale); + layout->AddView(_FindInsertIndex(view, layout), view, scale); } } } + int32 _FindInsertIndex(PartitionView* view, BGroupLayout* layout) const + { + int32 insertIndex = 0; + int32 count = layout->CountItems(); + for (int32 i = 0; i < count; i++) { + BLayoutItem* item = layout->ItemAt(i); + if (!item) + break; + PartitionView* sibling + = dynamic_cast(item->View()); + if (sibling && sibling->Offset() > view->Offset()) + break; + insertIndex++; + } + return insertIndex; + } typedef HashKey32 PartitionKey; typedef HashMap PartitionViewMap; @@ -421,8 +429,17 @@ fPartitionLayout->Unset(); - if (fDisk) + if (fDisk) { + // we need to prepare the disk for modifications, otherwise + // we cannot get information about available spaces on the + // device or any of its child partitions + // TODO: cancelling modifications here is of course undesired + // once we hold off the real modifications until an explicit + // command to write them to disk... +fDisk->PrepareModifications(); fDisk->VisitEachDescendant(fPartitionLayout); +fDisk->CancelModifications(); + } Invalidate(); } Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-01 14:50:06 UTC (rev 23811) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-01 18:02:04 UTC (rev 23812) @@ -50,6 +50,10 @@ virtual bool Visit(BDiskDevice* device) { fDiskCount++; + // if we don't prepare the device for modifications, + // we cannot get information about available empty + // regions on the device or child partitions +device->PrepareModifications(); _AddPartition(device); return false; // Don't stop yet! } @@ -68,7 +72,8 @@ // add any available space on it BPartitioningInfo info; - if (partition->GetPartitioningInfo(&info) >= B_OK) { + status_t ret = partition->GetPartitioningInfo(&info); + if (ret >= B_OK) { off_t offset; off_t size; for (int32 i = 0; @@ -76,6 +81,9 @@ i++) { fPartitionList->AddSpace(partition->ID(), offset, size); } + } else { + fprintf(stderr, "failed to get partitioning info: %s\n", + strerror(ret)); } } From bga at bug-br.org.br Fri Feb 1 19:40:46 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Fri, 01 Feb 2008 16:40:46 -0200 Subject: [Haiku-commits] r23812 - haiku/trunk/src/apps/drivesetup In-Reply-To: <200802011802.m11I25dG012679@sheep.berlios.de> References: <200802011802.m11I25dG012679@sheep.berlios.de> Message-ID: <47A367AE.5070401@bug-br.org.br> stippi at BerliOS wrote: > Author: stippi > Date: 2008-02-01 19:02:04 +0100 (Fri, 01 Feb 2008) > New Revision: 23812 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23812&view=rev > > Modified: > haiku/trunk/src/apps/drivesetup/DiskView.cpp > haiku/trunk/src/apps/drivesetup/MainWindow.cpp > Log: > * To be able to call BPartition::GetPartitioningIngo(), you need to call I know that Ingo did most of the partitioning stuff but, isn't it going way too far? ;) -Bruno From simontaylor1 at ntlworld.com Fri Feb 1 20:55:38 2008 From: simontaylor1 at ntlworld.com (Simon Taylor) Date: Fri, 1 Feb 2008 19:55:38 +0000 Subject: [Haiku-commits] r23812 - haiku/trunk/src/apps/drivesetup Message-ID: <20080201195456.VKZY17393.aamtaout02-winn.ispmail.ntl.com@smtp.ntlworld.com> Bruno Albuquerque wrote: > stippi at BerliOS wrote: >> Author: stippi >> Date: 2008-02-01 19:02:04 +0100 (Fri, 01 Feb 2008) >> New Revision: 23812 >> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23812&view=rev >> >> Modified: >> haiku/trunk/src/apps/drivesetup/DiskView.cpp >> haiku/trunk/src/apps/drivesetup/MainWindow.cpp >> Log: >> * To be able to call BPartition::GetPartitioningIngo(), you need to call > > I know that Ingo did most of the partitioning stuff but, isn't it going > way too far? ;) It will certainly add fuel to the rumours of the Haiku Inc. cloning experiments - though I like the idea of a free Ingo with every image downloaded to provide a more personal approach to partitioning problems! Simon ps: I'm up to date with the commit list for the first time since September, yay! > -Bruno > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > ----------------------------------------- Email sent from www.virginmedia.com/email Virus-checked using McAfee(R) Software and scanned for spam From oruizdorantes at mail.berlios.de Fri Feb 1 21:48:57 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 1 Feb 2008 21:48:57 +0100 Subject: [Haiku-commits] r23813 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802012048.m11KmvwB007608@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-01 21:48:56 +0100 (Fri, 01 Feb 2008) New Revision: 23813 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23813&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c Log: Clean ups, and removed warnings. Some definitions moved to more generic headers Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2008-02-01 20:48:56 UTC (rev 23813) @@ -27,7 +27,6 @@ #define BT_SURVIVE_WITHOUT_HCI #define BT_SURVIVE_WITHOUT_NET_BUFFERS -//#define BT_IOCTLS_PASS_SIZE #endif Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-01 20:48:56 UTC (rev 23813) @@ -18,8 +18,9 @@ #include #include "snet_buffer.h" -#include -#include +#include +#include +#include #define BT_DEBUG_THIS_MODULE #include @@ -34,7 +35,7 @@ /* Modules */ static char* usb_name = B_USB_MODULE_NAME; -static char* hci_name = B_BT_HCI_MODULE_NAME; +static char* hci_name = BT_HCI_MODULE_NAME; usb_module_info *usb = NULL; bt_hci_module_info *hci = NULL; @@ -149,7 +150,6 @@ static void kill_device(bt_usb_dev* dev) { - uint16 i; debugf("remove_device(%p)\n", dev); delete_sem(dev->lock); @@ -217,9 +217,9 @@ status_t err = B_ERROR; bt_usb_dev* new_bt_dev = spawn_device(dev); - int e, i; + int e; - debugf("device_added(%ld, %p)\n", dev, new_bt_dev); + debugf("device_added(%p, %p)\n", dev, new_bt_dev); if (new_bt_dev == NULL) { flowf("Couldn't allocate device record.\n"); @@ -339,7 +339,7 @@ kill_device(new_bt_dev); bail_no_mem: *cookie = NULL; -done: + return err; } @@ -361,7 +361,7 @@ // TODO: Consider some other place // TX for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { - if (i = BT_COMMAND) + if (i == BT_COMMAND) while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { snb_free(item); } @@ -514,7 +514,7 @@ if (bdev == NULL) panic("bad cookie"); - debugf("device_close() called on %s\n", DEVICE_PATH, bdev->hdev ); + debugf("device_close() called on %ld\n", bdev->hdev ); if (!TEST_AND_CLEAR(&bdev->state, RUNNING) ) { @@ -581,13 +581,13 @@ device_control(void *cookie, uint32 msg, void *params, size_t size) { status_t err = B_ERROR; - bt_usb_dev* dev = (bt_usb_dev*)cookie; + bt_usb_dev* bdev = (bt_usb_dev*)cookie; snet_buffer* snbuf; TOUCH(size); debugf("ioctl() opcode %ld size %ld.\n", msg, size); - if (dev == NULL) { + if (bdev == NULL) { flowf("Bad cookie\n"); return B_BAD_VALUE; } @@ -597,7 +597,7 @@ return B_BAD_VALUE; } - acquire_sem(dev->lock); + acquire_sem(bdev->lock); switch (msg) { case ISSUE_BT_COMMAND: @@ -616,12 +616,12 @@ snbuf = snb_create(size); snb_put(snbuf, params, size); - err = send_command(dev->hdev, snbuf); + err = submit_tx_command(bdev, snbuf); break; - case ISSUE_STATICS: - memcpy(params, &dev->stat, sizeof(bt_hci_statistics)); + case GET_STATICS: + memcpy(params, &bdev->stat, sizeof(bt_hci_statistics)); err = B_OK; break; @@ -631,7 +631,7 @@ break; } - release_sem(dev->lock); + release_sem(bdev->lock); return err; } @@ -640,7 +640,7 @@ static status_t device_read(void *cookie, off_t pos, void *buf, size_t *count) { - debugf("Reading... pos = %ld || count = %ld\n", pos, *count); + debugf("Reading... count = %ld\n", *count); *count = 0; return B_OK; Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2008-02-01 20:48:56 UTC (rev 23813) @@ -12,7 +12,8 @@ #include #include -#include +#include +#include #include @@ -37,9 +38,9 @@ // Expecting nobody is gonna have 16 USB-BT dongles connected in their system #define MAX_BT_GENERIC_USB_DEVICES 16 -extern usb_module_info *usb; -extern bt_hci_module_info *hci; -extern struct net_buffer_module_info *nb; +extern usb_module_info* usb; +extern bt_hci_module_info* hci; +extern struct net_buffer_module_info* nb; #define MAX_COMMAND_WINDOW 1 #define MAX_ACL_OUT_WINDOW 4 Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-02-01 20:48:56 UTC (rev 23813) @@ -10,39 +10,53 @@ #include "h2upper.h" #include "h2util.h" -#include -#include -#include +#include +#include +#include #include +#include + #define BT_DEBUG_THIS_MODULE -#include "btDebug.h" +#include -#if 0 -#pragma mark --- RX Complete --- + +/* Forward declaration */ + +#ifndef HAIKU_TARGET_PLATFORM_HAIKU +void acl_tx_complete(void* cookie, uint32 status, void* data, uint32 actual_len); +void acl_rx_complete(void* cookie, uint32 status, void* data, uint32 actual_len); +void command_complete(void* cookie, uint32 status, void* data, uint32 actual_len); +void event_complete(void* cookie, uint32 status, void* data, uint32 actual_len); +#else +/* TODO: propagate this definitions */ +void acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len); +void acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len); +void command_complete(void* cookie, status_t status, void* data, size_t actual_len); +void event_complete(void* cookie, status_t status, void* data, size_t actual_len); #endif -status_t +static status_t assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count) { - net_buffer* nbuf; - snet_buffer* snbuf; + net_buffer* nbuf = NULL; + snet_buffer* snbuf = NULL; - size_t currentPacketLen; - size_t expectedPacketLen; + size_t currentPacketLen = 0; + size_t expectedPacketLen = 0; bdev->stat.bytesRX += count; + if (type == BT_EVENT) + snbuf = bdev->eventRx; + else + nbuf = bdev->nbufferRx[type]; + while (count) { - if (type == BT_EVENT) - snbuf = bdev->eventRx; - else - nbuf = bdev->nbufferRx[type]; - debugf("count %d %p %p\n",count, nbuf, nb); @@ -141,11 +155,19 @@ /* in case in the pipe there is info about the next buffer ... */ count -= currentPacketLen; data += currentPacketLen; - } + } + + return B_OK; } + +#if 0 +#pragma mark --- RX Complete --- +#endif + + void -event_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +event_complete(void* cookie, status_t status, void* data, size_t actual_len) { bt_usb_dev* bdev = cookie; @@ -180,7 +202,7 @@ } void -acl_rx_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len) { bt_usb_dev* bdev = cookie; status_t err; @@ -200,12 +222,12 @@ err = usb->queue_bulk(bdev->bulk_in_ep->handle, data, max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in), - acl_rx_complete, bdev); + acl_rx_complete, (void*) bdev); if (err != B_OK ) { reuse_room(&bdev->aclRoom, data); bdev->stat.rejectedRX++; - debugf("RX acl resubmittion failed %s\n",strerror(err)); + debugf("RX acl resubmittion failed %s\n", strerror(err)); } else { bdev->stat.acceptedRX++; @@ -228,14 +250,14 @@ err = usb->queue_interrupt(bdev->intr_in_ep->handle, buf, size , - event_complete, bdev); + event_complete, (void*) bdev); if (err != B_OK ) { reuse_room(&bdev->eventRoom, buf); bdev->stat.rejectedRX++; } else { bdev->stat.acceptedRX++; - debugf("Accepted RX Event\n",bdev->stat.acceptedRX); + debugf("Accepted RX Event %d\n", bdev->stat.acceptedRX); } return err; @@ -282,14 +304,18 @@ #pragma mark --- TX Complete --- #endif +#ifndef HAIKU void -command_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +command_complete(void* cookie, status_t status, void* data, size_t actual_len) +#else +void +command_complete(void* cookie, uint32 status, void* data, size_t actual_len) +#endif { snet_buffer* snbuf = (snet_buffer*) cookie; bt_usb_dev* bdev = snb_cookie(snbuf); - status_t err; - debugf("%d %02x:%02x:%02x:\n", actual_len, ((uint8*)data)[0],((uint8*)data)[1],((uint8*)data)[2]); + debugf("%ld %02x:%02x:%02x:\n", actual_len, ((uint8*)data)[0],((uint8*)data)[1],((uint8*)data)[2]); if (status != B_OK) { @@ -310,13 +336,18 @@ #endif } + void -aclTxComplete(void* cookie, uint32 status, void* data, uint32 actual_len) +#ifndef HAIKU_TARGET_PLATFORM_HAIKU +acl_tx_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +#else +acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len) +#endif + { net_buffer* nbuf = (net_buffer*) cookie; bt_usb_dev* bdev = GET_DEVICE(nbuf); - status_t err; if (status != B_OK) { @@ -357,7 +388,7 @@ err = usb->queue_request(bdev->dev, bRequestType, bRequest, value, wIndex, wLength, snb_get(snbuf), wLength //??? - ,command_complete, snbuf); + ,command_complete, (void*) snbuf); if (err != B_OK ) { bdev->stat.rejectedTX++; @@ -379,7 +410,7 @@ err = usb->queue_bulk(bdev->bulk_out_ep->handle, nb_get_whole_buffer(nbuf), nbuf->size, - aclTxComplete, nbuf); + acl_tx_complete, (void*) nbuf); if (err != B_OK ) { bdev->stat.rejectedTX++; Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c 2008-02-01 20:48:56 UTC (rev 23813) @@ -5,17 +5,20 @@ * */ + +#include + +#include +#include + #include "h2upper.h" #include "h2transactions.h" +#include "snet_buffer.h" #define BT_DEBUG_THIS_MODULE -#include "btDebug.h" +#include -#include -#include -#include "snet_buffer.h" - /* TODO: split for commands and comunication(ACL&SCO) */ void sched_tx_processing(bt_usb_dev* bdev) @@ -84,7 +87,7 @@ post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf) { - status_t err; + status_t err = B_OK; port_id port; if (hci == NULL) { @@ -92,20 +95,19 @@ err = B_ERROR; // ERROR but we will try to send if its a event! - if (type != BT_EVENT) { - err = B_ERROR; - } else { - snet_buffer* snbuf = (snet_buffer*)buf; + if (type == BT_EVENT) { + + snet_buffer* snbuf = (snet_buffer*) buf; flowf("HCI not present, Posting to userland\n"); port = find_port(BT_USERLAND_PORT_NAME); if (port != B_NAME_NOT_FOUND) { - err = write_port_etc(port, PACK_HEADER_PORT(bdev->num,type), + err = write_port_etc(port, PACK_PORTCODE(type,bdev->hdev, -1), snb_get(snbuf), snb_size(snbuf), B_TIMEOUT, 1*1000*1000); if (err != B_OK) - debugf("Error posting userland %s\n",strerror(err)); + debugf("Error posting userland %s\n", strerror(err)); } else { Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.h 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.h 2008-02-01 20:48:56 UTC (rev 23813) @@ -12,10 +12,9 @@ #include "h2generic.h" -#define PACK_HEADER_PORT(x,y) (x<<24|y<<16) - status_t post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf); status_t send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf); +status_t send_command(hci_id hid, snet_buffer* snbuf); void sched_tx_processing(bt_usb_dev* bdev); Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-02-01 20:48:56 UTC (rev 23813) @@ -5,22 +5,23 @@ * */ +#include + #include "h2upper.h" #include "h2util.h" #include "h2transactions.h" +#include +#include +#include + #define BT_DEBUG_THIS_MODULE -#include "btDebug.h" +#include -#include -#include -#include -#include void* nb_get_whole_buffer(net_buffer* nbuf) { - void* conPointer; status_t err; @@ -52,7 +53,7 @@ return conPointer; free: - free(nbuf->COOKIEFIELD); + free((void*) nbuf->COOKIEFIELD); fail: return NULL; } @@ -99,9 +100,11 @@ return header->elen; } default: - - break; + + break; } + + return B_ERROR; } #if 0 Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h 2008-02-01 20:48:56 UTC (rev 23813) @@ -12,7 +12,7 @@ #include "h2generic.h" -/* net buffer utils for ACL, to be reviwed */ +/* net buffer utils for ACL, to be reviewed */ #define DEVICEFIELD type #define SET_DEVICE(nbuf,hid) (nbuf->DEVICEFIELD=(nbuf->DEVICEFIELD&0xFFF0)|(hid&0xF)) #define GET_DEVICE(nbuf) fetch_device(NULL,(nbuf->DEVICEFIELD&0x0F)) Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-02-01 18:02:04 UTC (rev 23812) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-02-01 20:48:56 UTC (rev 23813) @@ -7,6 +7,8 @@ #include "snet_buffer.h" +#include +#include struct snet_buffer { struct list_link link; From oruizdorantes at mail.berlios.de Fri Feb 1 21:55:18 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 1 Feb 2008 21:55:18 +0100 Subject: [Haiku-commits] r23814 - in haiku/trunk/src/add-ons/kernel/drivers/bluetooth: . h2 h2/h2generic Message-ID: <200802012055.m11KtInY008183@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-01 21:55:18 +0100 (Fri, 01 Feb 2008) New Revision: 23814 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23814&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/Jamfile haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/Jamfile haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile Log: Add bluetooth transport drivers jamfiles Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/Jamfile 2008-02-01 20:48:56 UTC (rev 23813) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/Jamfile 2008-02-01 20:55:18 UTC (rev 23814) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src add-ons kernel drivers bluetooth ; + +SubInclude HAIKU_TOP src add-ons kernel drivers bluetooth h2 ; Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/Jamfile 2008-02-01 20:48:56 UTC (rev 23813) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/Jamfile 2008-02-01 20:55:18 UTC (rev 23814) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src add-ons kernel drivers bluetooth h2 ; + +SubInclude HAIKU_TOP src add-ons kernel drivers bluetooth h2 h2generic ; Added: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile 2008-02-01 20:48:56 UTC (rev 23813) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile 2008-02-01 20:55:18 UTC (rev 23814) @@ -0,0 +1,18 @@ +SubDir HAIKU_TOP src add-ons kernel drivers bluetooth h2 h2generic ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +UsePrivateHeaders net kernel bluetooth ; + +KernelAddon h2generic : + h2generic.c + h2transactions.c + h2upper.c + h2util.c + snet_buffer.c + ; + +Package haiku-h2generic-cvs : + h2generic : + boot home config add-ons kernel drivers bin ; +PackageDriverSymLink haiku-hda-cvs : bluetooth h2 h2generic ; \ No newline at end of file From oruizdorantes at mail.berlios.de Fri Feb 1 21:59:14 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 1 Feb 2008 21:59:14 +0100 Subject: [Haiku-commits] r23815 - in haiku/trunk/headers/private: . bluetooth Message-ID: <200802012059.m11KxEkA008392@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-01 21:59:14 +0100 (Fri, 01 Feb 2008) New Revision: 23815 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23815&view=rev Added: haiku/trunk/headers/private/bluetooth/ haiku/trunk/headers/private/bluetooth/bluetoothserver_p.h haiku/trunk/headers/private/bluetooth/btDebug.h Log: Add private bluetooth headers being used in the kit and the future server Added: haiku/trunk/headers/private/bluetooth/bluetoothserver_p.h =================================================================== --- haiku/trunk/headers/private/bluetooth/bluetoothserver_p.h 2008-02-01 20:55:18 UTC (rev 23814) +++ haiku/trunk/headers/private/bluetooth/bluetoothserver_p.h 2008-02-01 20:59:14 UTC (rev 23815) @@ -0,0 +1,12 @@ +#ifndef _BLUETOOTH_SERVER_PRIVATE_H +#define _BLUETOOTH_SERVER_PRIVATE_H + + +#define BLUETOOTH_SIGNATURE "application/x-vnd.Be-bluetooth_server" + +#define BT_MSG_COUNT_LOCAL_DEVICES 'btCd' +#define BT_MSG_ADQUIRE_LOCAL_DEVICE 'btAd' +#define BT_MSG_GET_FRIENDLY_NAME 'btFn' +#define BT_MSG_GET_ADDRESS 'btGa' + +#endif Added: haiku/trunk/headers/private/bluetooth/btDebug.h =================================================================== --- haiku/trunk/headers/private/bluetooth/btDebug.h 2008-02-01 20:55:18 UTC (rev 23814) +++ haiku/trunk/headers/private/bluetooth/btDebug.h 2008-02-01 20:59:14 UTC (rev 23815) @@ -0,0 +1,61 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + + +#ifdef BT_DEBUG_THIS_MODULE + #ifndef MODULE_NAME + //#warning MODULE_NAME not defined for Haiku BT debugging tools + #define MODULE_NAME "BT" + #endif + + #ifndef SUBMODULE_NAME + //#warning SUBMODULE_NAME not defined for Haiku BT debugging tools + #define SUBMODULE_NAME "" + #endif + + #ifndef SUBMODULE_COLOR + //#warning SUBMODULE_COLOR not defined for Haiku BT debugging tools + #define SUBMODULE_COLOR 38 + #endif + + #define debugf(a,param...) dprintf("\x1b[%dm" MODULE_NAME " " SUBMODULE_NAME " " "%s\x1b[0m: " a,SUBMODULE_COLOR,__FUNCTION__, param); + #define flowf(a) dprintf("\x1b[%dm" MODULE_NAME " " SUBMODULE_NAME " " "%s\x1b[0m: " a,SUBMODULE_COLOR,__FUNCTION__); +#else + #define debugf(a,param...) + #define flowf(a,param...) +#endif +#undef BT_DEBUG_THIS_MODULE + +#define TOUCH(x) ((void)(x)) + +/* */ +#if 0 +#pragma mark - Kernel Auxiliary Stuff - +#endif + +/* tricking bits */ +#define SET_BIT(byte,bit_mask) {byte|=bit_mask;} +#define CLEAR_BIT(byte,bit_mask) {byte&=~bit_mask;} +#define GET_BIT(byte,bit_mask) ((byte&bit_mask)!=0) +#define TOOGLE_BIT(byte,bit_mask) {byte^=bit_mask;} + +//#define TEST_AND_SET(byte,bit_mask) (((byte|=bit_mask)&bit_mask)!=0) +//#define TEST_AND_CLEAR(byte,bit_mask) (((byte&=~bit_mask)&bit_mask)!=0) + +static inline uint32 TEST_AND_SET(uint32 *byte, uint32 bit_mask) { + + uint32 val = (*byte&bit_mask)!=0; + *byte |= bit_mask; + return val; +} + +static inline uint32 TEST_AND_CLEAR(uint32* byte, uint32 bit_mask) { + + uint32 val = (*byte&bit_mask)!=0; + *byte &= ~bit_mask; + return val; +} From ingo_weinhold at gmx.de Fri Feb 1 22:11:38 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 01 Feb 2008 22:11:38 +0100 Subject: [Haiku-commits] r23812 - haiku/trunk/src/apps/drivesetup In-Reply-To: <47A367AE.5070401@bug-br.org.br> References: <200802011802.m11I25dG012679@sheep.berlios.de> <47A367AE.5070401@bug-br.org.br> Message-ID: <20080201221138.526.2@knochen-vm.nameserver> On 2008-02-01 at 19:40:46 [+0100], Bruno Albuquerque wrote: > stippi at BerliOS wrote: > > Author: stippi > > Date: 2008-02-01 19:02:04 +0100 (Fri, 01 Feb 2008) > > New Revision: 23812 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23812&view=rev > > > > Modified: > > haiku/trunk/src/apps/drivesetup/DiskView.cpp > > haiku/trunk/src/apps/drivesetup/MainWindow.cpp > > Log: > > * To be able to call BPartition::GetPartitioningIngo(), you need to call > > I know that Ingo did most of the partitioning stuff but, isn't it going > way too far? ;) I swear I'm totally innocent in this case. :-) CU, Info From oruizdorantes at mail.berlios.de Fri Feb 1 22:17:03 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 1 Feb 2008 22:17:03 +0100 Subject: [Haiku-commits] r23816 - in haiku/trunk/headers/os/bluetooth: . HCI Message-ID: <200802012117.m11LH30E009992@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-01 22:17:02 +0100 (Fri, 01 Feb 2008) New Revision: 23816 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23816&view=rev Added: haiku/trunk/headers/os/bluetooth/HCI/ haiku/trunk/headers/os/bluetooth/HCI/btHCI.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h haiku/trunk/headers/os/bluetooth/bluetooth_util.h Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h Log: Add 'public' headers in order all stuff actually compiles Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,41 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_H_ +#define _BTHCI_H_ + +/* typedefs */ +typedef int32 hci_id; + +typedef enum { H2 = 2, H3, H4, H5 } transport_type; + +// TODO: something more authomatic here? +#define HCI_NUM_PACKET_TYPES 5 +typedef enum { BT_COMMAND = 0, + BT_EVENT, + BT_ACL, + BT_SCO, + BT_ESCO + } bt_packet_t; + + +/* packets sizes */ +#define HCI_MAX_ACL_SIZE 1024 +#define HCI_MAX_SCO_SIZE 255 +#define HCI_MAX_EVENT_SIZE 260 +#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) + +/* fields sizes */ +#define HCI_LAP_SIZE 3 /* LAP */ +#define HCI_LINK_KEY_SIZE 16 /* link key */ +#define HCI_PIN_SIZE 16 /* PIN */ +#define HCI_EVENT_MASK_SIZE 8 /* event mask */ +#define HCI_CLASS_SIZE 3 /* class */ +#define HCI_FEATURES_SIZE 8 /* LMP features */ +#define HCI_DEVICE_NAME_SIZE 248 /* unit name size */ + +#endif \ No newline at end of file Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,39 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_ACL_H_ +#define _BTHCI_ACL_H_ + +#include +#include + +#define HCI_ACL_HDR_SIZE 4 + +struct hci_acl_header { + uint16 handle; /* Handle & Flags(PB, BC) */ + uint16 alen; +} __attribute__ ((packed)) ; + +/* ACL handle and flags pack/unpack */ +#define pack_acl_handle_flags(h, pb, bc) (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) +#define get_acl_handle(h) ((h) & 0x0fff) +#define get_acl_pb_flag(h) (((h) & 0x3000) >> 12) +#define get_acl_bc_flag(h) (((h) & 0xc000) >> 14) + +/* PB flag values */ +/* 00 - reserved for future use */ +#define HCI_ACL_PACKET_FRAGMENT 0x1 +#define HCI_ACL_PACKET_START 0x2 +/* 11 - reserved for future use */ + +/* BC flag values */ +#define HCI_ACL_POINT2POINT 0x0 /* only Host controller to Host */ +#define HCI_ACL_BROADCAST_ACTIVE 0x1 /* both directions */ +#define HCI_ACL_BROADCAST_PICONET 0x2 /* both directions */ + /* 11 - reserved for future use */ + +#endif Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,342 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_COMMAND_H_ +#define _BTHCI_COMMAND_H_ + +#include +#include + +#define HCI_COMMAND_HDR_SIZE 3 + +struct hci_command_header { + uint16 opcode; /* OCF & OGF */ + uint8 clen; +} __attribute__ ((packed)); + + +/* Command opcode pack/unpack */ +#define hci_opcode_pack(ogf, ocf) (uint16)((ocf & 0x03ff)|(ogf << 10)) +#define hci_opcode_ogf(op) (op >> 10) +#define hci_opcode_ocf(op) (op & 0x03ff) + + +/* - Informational Parameters Command definition - */ +#define OGF_INFORMATIONAL_PARAM 0x04 + + #define OCF_READ_LOCAL_VERSION 0x0001 + struct hci_rp_read_loc_version { + uint8 status; + uint8 hci_ver; + uint16 hci_rev; + uint8 lmp_ver; + uint16 manufacturer; + uint16 lmp_subver; + } __attribute__ ((packed)); + + #define OCF_READ_LOCAL_FEATURES 0x0003 + struct hci_rp_read_loc_features { + uint8 status; + uint8 features[8]; + } __attribute__ ((packed)); + + #define OCF_READ_BUFFER_SIZE 0x0005 + struct hci_rp_read_buffer_size { + uint8 status; + uint16 acl_mtu; + uint8 sco_mtu; + uint16 acl_max_pkt; + uint16 sco_max_pkt; + } __attribute__ ((packed)); + + #define OCF_READ_BD_ADDR 0x0009 + struct hci_rp_read_bd_addr { + uint8 status; + bdaddr_t bdaddr; + } __attribute__ ((packed)); + +/* - Host Controller and Baseband Command definition - */ +#define OGF_CONTROL_BASEBAND 0x03 + + #define OCF_RESET 0x0003 + /*struct hci_reset { + void no_fields; + } __attribute__ ((packed));*/ + + #define OCF_SET_EVENT_FLT 0x0005 + struct hci_cp_set_event_flt { + uint8 flt_type; + uint8 cond_type; + uint8 condition[0]; + } __attribute__ ((packed)); + + #define OCF_READ_STORED_LINK_KEY 0x000D + struct hci_read_stored_link_key { + bdaddr_t bdaddr; + uint8 all_keys_flag; + } __attribute__ ((packed)); + struct hci_read_stored_link_key_reply { + uint8 status; + uint16 max_num_keys; + uint16 num_keys_read; + } __attribute__ ((packed)); + + #define OCF_WRITE_STORED_LINK_KEY 0x0011 + struct hci_write_stored_link_key { + uint8 num_keys_to_write; + // these are repeated "num_keys_write" times + bdaddr_t bdaddr; + uint8 key[HCI_LINK_KEY_SIZE]; + } __attribute__ ((packed)); + struct hci_write_stored_link_key_reply { + uint8 status; + uint8 num_keys_written; + } __attribute__ ((packed)); + + + #define OCF_WRITE_LOCAL_NAME 0x0013 + #define OCF_READ_LOCAL_NAME 0x0014 + struct hci_read_local_name { + uint8 status; + char local_name[248]; + } __attribute__ ((packed)); + + #define OCF_WRITE_CA_TIMEOUT 0x0016 + #define OCF_WRITE_PG_TIMEOUT 0x0018 + + #define OCF_WRITE_SCAN_ENABLE 0x001A + #define HCI_SCAN_DISABLED 0x00 + #define HCI_SCAN_INQUIRY 0x01 + #define HCI_SCAN_PAGE 0x02 + #define HCI_SCAN_INQUIRY_PAGE 0x03 + struct hci_write_scan_enable { + uint8 scan; + } __attribute__ ((packed)); + + #define OCF_READ_AUTH_ENABLE 0x001F + #define OCF_WRITE_AUTH_ENABLE 0x0020 + #define HCI_AUTH_DISABLED 0x00 + #define HCI_AUTH_ENABLED 0x01 + struct hci_write_authentication_enable { + uint8 authentication; + } __attribute__ ((packed)); + + #define OCF_READ_ENCRYPT_MODE 0x0021 + #define OCF_WRITE_ENCRYPT_MODE 0x0022 + #define HCI_ENCRYPT_DISABLED 0x00 + #define HCI_ENCRYPT_P2P 0x01 + #define HCI_ENCRYPT_BOTH 0x02 + struct hci_write_encryption_mode_enable { + uint8 encryption; + } __attribute__ ((packed)); + + /* Filter types */ + #define HCI_FLT_CLEAR_ALL 0x00 + #define HCI_FLT_INQ_RESULT 0x01 + #define HCI_FLT_CONN_SETUP 0x02 + + /* CONN_SETUP Condition types */ + #define HCI_CONN_SETUP_ALLOW_ALL 0x00 + #define HCI_CONN_SETUP_ALLOW_CLASS 0x01 + #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 + + /* CONN_SETUP Conditions */ + #define HCI_CONN_SETUP_AUTO_OFF 0x01 + #define HCI_CONN_SETUP_AUTO_ON 0x02 + + #define OCF_READ_CLASS_OF_DEV 0x0023 + + struct hci_read_dev_class_reply { + uint8 status; + uint8 dev_class[3]; + } __attribute__ ((packed)); + + #define OCF_WRITE_CLASS_OF_DEV 0x0024 + struct hci_write_dev_class { + uint8 dev_class[3]; + } __attribute__ ((packed)); + + #define OCF_READ_VOICE_SETTING 0x0025 + struct hci_rp_read_voice_setting { + uint8 status; + uint16 voice_setting; + } __attribute__ ((packed)); + + #define OCF_WRITE_VOICE_SETTING 0x0026 + struct hci_cp_write_voice_setting { + uint16 voice_setting; + } __attribute__ ((packed)); + + #define OCF_HOST_BUFFER_SIZE 0x0033 + struct hci_cp_host_buffer_size { + uint16 acl_mtu; + uint8 sco_mtu; + uint16 acl_max_pkt; + uint16 sco_max_pkt; + } __attribute__ ((packed)); + + /* Link Control Command definition */ + #define OGF_LINK_CONTROL 0x01 + #define OCF_CREATE_CONN 0x0005 + struct hci_cp_create_conn { + bdaddr_t bdaddr; + uint16 pkt_type; + uint8 pscan_rep_mode; + uint8 pscan_mode; + uint16 clock_offset; + uint8 role_switch; + } __attribute__ ((packed)); + + #define OCF_ACCEPT_CONN_REQ 0x0009 + struct hci_cp_accept_conn_req { + bdaddr_t bdaddr; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_REJECT_CONN_REQ 0x000a + struct hci_cp_reject_conn_req { + bdaddr_t bdaddr; + uint8 reason; + } __attribute__ ((packed)); + + #define OCF_DISCONNECT 0x0006 + struct hci_disconnect { + uint16 handle; + uint8 reason; + } __attribute__ ((packed)); + + #define OCF_ADD_SCO 0x0007 + struct hci_cp_add_sco { + uint16 handle; + uint16 pkt_type; + } __attribute__ ((packed)); + + #define OCF_INQUIRY 0x0001 + struct hci_cp_inquiry { + uint8 lap[3]; + /* Constants related the inquiry process */ + #define B_BT_GIAC 0x9E8B33 + #define B_BT_LIAC 0x9E8B00 + uint8 length; + uint8 num_rsp; + } __attribute__ ((packed)); + + #define OCF_INQUIRY_CANCEL 0x0002 + + #define OCF_LINK_KEY_REPLY 0x000B + struct hci_cp_link_key_reply { + bdaddr_t bdaddr; + uint8 link_key[16]; + } __attribute__ ((packed)); + + #define OCF_LINK_KEY_NEG_REPLY 0x000C + struct hci_cp_link_key_neg_reply { + bdaddr_t bdaddr; + } __attribute__ ((packed)); + + #define OCF_PIN_CODE_REPLY 0x000D + struct hci_cp_pin_code_reply { + bdaddr_t bdaddr; + uint8 pin_len; + uint8 pin_code[16]; + } __attribute__ ((packed)); + + #define OCF_PIN_CODE_NEG_REPLY 0x000E + struct hci_cp_pin_code_neg_reply { + bdaddr_t bdaddr; + } __attribute__ ((packed)); + + #define OCF_CHANGE_CONN_PTYPE 0x000F + struct hci_cp_change_conn_ptype { + uint16 handle; + uint16 pkt_type; + } __attribute__ ((packed)); + + #define OCF_AUTH_REQUESTED 0x0011 + struct hci_cp_auth_requested { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_SET_CONN_ENCRYPT 0x0013 + struct hci_cp_set_conn_encrypt { + uint16 handle; + uint8 encrypt; + } __attribute__ ((packed)); + + #define OCF_CHANGE_CONN_LINK_KEY 0x0015 + struct hci_cp_change_conn_link_key { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_REMOTE_NAME_REQUEST 0x0019 + struct hci_remote_name_request { + bdaddr_t bdaddr; + uint8 pscan_rep_mode; + uint8 reserved; + uint16 clock_offset; + } __attribute__ ((packed)); + + #define OCF_READ_REMOTE_FEATURES 0x001B + struct hci_cp_read_rmt_features { + uint16 handle; + } __attribute__ ((packed)); + + #define OCF_READ_REMOTE_VERSION 0x001D + struct hci_cp_read_rmt_version { + uint16 handle; + } __attribute__ ((packed)); + + +/* Link Policy Command definition */ +#define OGF_LINK_POLICY 0x02 + + #define OCF_ROLE_DISCOVERY 0x0009 + struct hci_cp_role_discovery { + uint16 handle; + } __attribute__ ((packed)); + struct hci_rp_role_discovery { + uint8 status; + uint16 handle; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_READ_LINK_POLICY 0x000C + struct hci_cp_read_link_policy { + uint16 handle; + } __attribute__ ((packed)); + struct hci_rp_read_link_policy { + uint8 status; + uint16 handle; + uint16 policy; + } __attribute__ ((packed)); + + #define OCF_SWITCH_ROLE 0x000B + struct hci_cp_switch_role { + bdaddr_t bdaddr; + uint8 role; + } __attribute__ ((packed)); + + #define OCF_WRITE_LINK_POLICY 0x000D + struct hci_cp_write_link_policy { + uint16 handle; + uint16 policy; + } __attribute__ ((packed)); + struct hci_rp_write_link_policy { + uint8 status; + uint16 handle; + } __attribute__ ((packed)); + +/* Status params */ +#define OGF_STATUS_PARAM 0x05 + +/* Testing commands */ +#define OGF_TESTING_CMD 0x3E + +/* Vendor specific commands */ +#define OGF_VENDOR_CMD 0x3F + +#endif Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,293 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_EVENT_H_ +#define _BTHCI_EVENT_H_ + +#include + +#define HCI_EVENT_HDR_SIZE 2 + +struct hci_event_header { + uint8 evt; + uint8 elen; +} __attribute__ ((packed)); + + +/* ---- HCI Events ---- */ +#define HCI_EVENT_INQUIRY_COMPLETE 0x01 + +#define HCI_EVENT_INQUIRY_RESULT 0x02 +struct inquiry_info { + bdaddr_t bdaddr; + uint8 pscan_rep_mode; + uint8 pscan_period_mode; + uint8 pscan_mode; + uint8 dev_class[3]; + uint16 clock_offset; +} __attribute__ ((packed)); + +#define HCI_EVENT_CONN_COMPLETE 0x03 +struct hci_ev_conn_complete { + uint8 status; + uint16 handle; + bdaddr_t bdaddr; + uint8 link_type; + uint8 encrypt_mode; +} __attribute__ ((packed)); + +#define HCI_EVENT_CONN_REQUEST 0x04 +struct hci_ev_conn_request { + bdaddr_t bdaddr; + uint8 dev_class[3]; + uint8 link_type; +} __attribute__ ((packed)); + +#define HCI_EVENT_DISCONNECTION_COMPLETE 0x05 +struct hci_disconnection_complete_reply { + uint8 status; + uint16 handle; + uint8 reason; +} __attribute__ ((packed)); + +#define HCI_EVENT_AUTH_COMPLETE 0x06 +struct hci_ev_auth_complete { + uint8 status; + uint16 handle; +} __attribute__ ((packed)); + +#define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07 +struct hci_remote_name_request_complete_reply { + uint8 status; + bdaddr_t bdaddr; + char remote_name[248]; +} __attribute__ ((packed)); + +#define HCI_EVENT_ENCRYPT_CHANGE 0x08 +struct hci_ev_encrypt_change { + uint8 status; + uint16 handle; + uint8 encrypt; +} __attribute__ ((packed)); + +#define HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 +struct hci_ev_change_conn_link_key_complete { + uint8 status; + uint16 handle; +} __attribute__ ((packed)); + +#define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a +struct hci_ev_master_link_key_complete { + uint8 status; /* 0x00 - success */ + uint16 handle; /* Connection handle */ + uint8 key_flag; /* Key flag */ +} __attribute__ ((packed)); + +#define HCI_EVENT_RMT_FEATURES 0x0B +struct hci_ev_rmt_features { + uint8 status; + uint16 handle; + uint8 features[8]; +} __attribute__ ((packed)); + +#define HCI_EVENT_RMT_VERSION 0x0C +struct hci_ev_rmt_version { + uint8 status; + uint16 handle; + uint8 lmp_ver; + uint16 manufacturer; + uint16 lmp_subver; +} __attribute__ ((packed)); + +#define HCI_EVENT_QOS_SETUP_COMPLETE 0x0D +struct hci_qos { + uint8 service_type; + uint32 token_rate; + uint32 peak_bandwidth; + uint32 latency; + uint32 delay_variation; +} __attribute__ ((packed)); +struct hci_ev_qos_setup_complete { + uint8 status; + uint16 handle; + struct hci_qos qos; +} __attribute__ ((packed)); + +#define HCI_EVENT_CMD_COMPLETE 0x0E +struct hci_ev_cmd_complete { + uint8 ncmd; + uint16 opcode; +} __attribute__ ((packed)); + +#define HCI_EVENT_CMD_STATUS 0x0F +struct hci_ev_cmd_status { + uint8 status; + uint8 ncmd; + uint16 opcode; +} __attribute__ ((packed)); + +#define HCI_EVENT_HARDWARE_ERROR 0x10 +struct hci_ev_hardware_error { + uint8 hardware_code; /* hardware error code */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_FLUSH_OCCUR 0x11 +struct hci_ev_flush_occur { + uint16 handle; /* connection handle */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_ROLE_CHANGE 0x12 +struct hci_ev_role_change { + uint8 status; + bdaddr_t bdaddr; + uint8 role; +} __attribute__ ((packed)); + +#define HCI_EVENT_NUM_COMP_PKTS 0x13 + struct handle_and_number { + uint16 handle; + uint16 num_completed; + } __attribute__ ((packed)); + + struct hci_ev_num_comp_pkts { + uint8 num_hndl; + // struct handle_and_number; hardcoded... + } __attribute__ ((packed)); + +#define HCI_EVENT_MODE_CHANGE 0x14 +struct hci_ev_mode_change { + uint8 status; + uint16 handle; + uint8 mode; + uint16 interval; +} __attribute__ ((packed)); + +#define HCI_EVENT_RETURN_LINK_KEYS 0x15 +struct link_key_info { + bdaddr_t bdaddr; + uint8 link_key[HCI_LINK_KEY_SIZE]; +} __attribute__ ((packed)) ; +struct hci_ev_return_link_keys { + uint8 num_keys; /* # of keys */ + struct link_key_info link_keys; /* As much as num_keys param */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_PIN_CODE_REQ 0x16 +struct hci_ev_pin_code_req { + bdaddr_t bdaddr; +} __attribute__ ((packed)); + +#define HCI_EVENT_LINK_KEY_REQ 0x17 +struct hci_ev_link_key_req { + bdaddr_t bdaddr; +} __attribute__ ((packed)); + +#define HCI_EVENT_LINK_KEY_NOTIFY 0x18 +struct hci_ev_link_key_notify { + bdaddr_t bdaddr; + uint8 link_key[16]; + uint8 key_type; +} __attribute__ ((packed)); + +#define HCI_EVENT_LOOPBACK_COMMAND 0x19 +struct hci_ev_loopback_command { + uint8 command[0]; /* depends of command */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a +struct hci_ev_data_buffer_overflow { + uint8 link_type; /* Link type */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_MAX_SLOT_CHANGE 0x1b +struct hci_ev_max_slot_change { + uint16 handle; /* connection handle */ + uint8 lmp_max_slots; /* Max. # of slots allowed */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c +struct hci_ev_read_clock_offset_compl { + uint8 status; /* 0x00 - success */ + uint16 handle; /* Connection handle */ + uint16 clock_offset; /* Clock offset */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d +struct hci_ev_con_pkt_type_changed { + uint8 status; /* 0x00 - success */ + uint16 handle; /* connection handle */ + uint16 pkt_type; /* packet type */ +} __attribute__ ((packed)); + +#define HCI_EVENT_QOS_VIOLATION 0x1e +struct hci_ev_qos_violation { + uint16 handle; /* connection handle */ +} __attribute__ ((packed)) ; + +#define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 +struct hci_ev_page_scan_rep_mode_change { + bdaddr_t bdaddr; /* destination address */ + uint8 page_scan_rep_mode; /* page scan repetition mode */ +} __attribute__ ((packed)); + +/* Events Beyond Bluetooth 1.1 */ +#define HCI_EVENT_FLOW_SPECIFICATION 0x21 +struct hci_ev_flow_specification { + uint8 status; + uint16 handle; + uint8 flags; + uint8 flow_direction; + uint8 service_type; + uint32 token_rate; + uint32 token_bucket_size; + uint32 peak_bandwidth; + uint32 access_latency; +} __attribute__ ((packed)); + +#define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI 0x22 +struct hci_ev_inquiry_info_with_rssi { + bdaddr_t bdaddr; + uint8 pscan_rep_mode; + uint8 pscan_period_mode; + uint8 dev_class[3]; + uint16 clock_offset; + int8 rssi; +} __attribute__ ((packed)); + +#define HCI_EVENT_REMOTE_EXTENDED_FEATURES 0x23 +struct hci_ev_remote_extended_features { + uint8 status; + uint16 handle; + uint8 page_number; + uint8 maximun_page_number; + uint64 extended_lmp_features; +} __attribute__ ((packed)); + +#define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETED 0x2C +struct hci_ev_sychronous_connection_completed { + uint8 status; + uint16 handle; + bdaddr_t bdaddr; + uint8 link_type; + uint8 transmission_interval; + uint8 retransmission_window; + uint16 rx_packet_length; + uint16 tx_packet_length; + uint8 air_mode; +} __attribute__ ((packed)); + +#define HCI_EVENT_SYNCHRONOUS_CONNECTION_CHANGED 0x2D +struct hci_ev_sychronous_connection_changed { + uint8 status; + uint16 handle; + uint8 transmission_interval; + uint8 retransmission_window; + uint16 rx_packet_length; + uint16 tx_packet_length; +} __attribute__ ((packed)); + +#endif \ No newline at end of file Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,39 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_MODULE_H_ +#define _BTHCI_MODULE_H_ + +/* includes */ + +#include +#include +#include + +/* defines */ +#define BT_HCI_MODULE_NAME "bus_managers/hci/v1" + +/* TODO: Possible definition of a bus manager of whatever is gonna be on the top */ +typedef struct bt_hci_module_info { + + /* registration */ + status_t (*RegisterDriver)(bt_hci_transport* desc, hci_id *id /*out*/, + bt_hci_device* cookie /*out*/ ); + status_t (*UnregisterDriver)(hci_id id); + + /* Transferences to be called from drivers */ + + status_t (*PostACL)(hci_id id, net_buffer* nbuf); + status_t (*PostSCO)(hci_id id, net_buffer* nbuf); + + /* Management */ + bt_hci_device* (*GetHciDevice)(hci_id id); + +} bt_hci_module_info ; + + +#endif \ No newline at end of file Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,93 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BTHCI_TRANSPORT_H_ +#define _BTHCI_TRANSPORT_H_ + +#include + +#include + + +typedef enum { ANCILLYANT = 1, + RUNNING, + LEAVING, + SENDING, + PROCESSING + } bt_transport_status_t; + +typedef uint8 bt_stat_t; +typedef struct bt_hci_statistics { + + bt_stat_t acceptedTX; + bt_stat_t rejectedTX; + bt_stat_t successfulTX; + bt_stat_t errorTX; + + bt_stat_t acceptedRX; + bt_stat_t rejectedRX; + bt_stat_t successfulRX; + bt_stat_t errorRX; + + bt_stat_t commandTX; + bt_stat_t eventRX; + bt_stat_t aclTX; + bt_stat_t aclRX; + bt_stat_t scoTX; + bt_stat_t scoRX; + bt_stat_t escoTX; + bt_stat_t escoRX; + + bt_stat_t bytesRX; + bt_stat_t bytesTX; + + +} bt_hci_statistics; + +/* TODO: Possible Hooks which drivers will have to provide */ +typedef struct bt_hci_transport { + + status_t (*SendCommand)(hci_id hci_dev, net_buffer* snbuf); + status_t (*SendPacket)(hci_id hci_dev, net_buffer* nbuf ); + status_t (*SendSCO)(hci_id hci_dev, net_buffer* nbuf ); + status_t (*DeliverStatistics)(bt_hci_statistics* statistics); + + transport_type kind; + char name[B_OS_NAME_LENGTH]; + +} bt_hci_transport; + +typedef struct bt_hci_device { + + transport_type kind; + char realName[B_OS_NAME_LENGTH]; + +} bt_hci_device; + + +/* Here the transport driver have some flags that */ +/* can be used to inform the upper layer about some */ +/* special behaouvior to perform */ + +#define BT_IGNORE_THIS_DEVICE (1<<0) +#define BT_SCO_NOT_WORKING (1<<1) +#define BT_WILL_NEED_A_RESET (1<<2) +#define BT_DIGIANSWER (1<<4) + +/* IOCTLS */ +#define ISSUE_BT_COMMAND (1<<0) +#define GET_STATICS (1<<1) +#define GET_NOTIFICATION_PORT (1<<2) +#define GET_HCI_ID (1<<3) + +#define PACK_PORTCODE(type,hid,data) ((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF)) + +/* Port drivers can use to send information (1 for all for + at moment refer to ioctl GET_NOTIFICATION_PORT)*/ +#define BT_USERLAND_PORT_NAME "BT kernel-user Land" + +#endif Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -11,8 +11,14 @@ #include #include +#include + +#include +#include + #include + namespace Bluetooth { class DiscoveryAgent; @@ -22,7 +28,9 @@ public: /* Possible throwing */ static LocalDevice* GetLocalDevice(); - static LocalDevice* GetLocalDevice(uint8 dev); + static uint32 GetLocalDeviceCount(); + + static LocalDevice* GetLocalDevice(hci_id hid); static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); DiscoveryAgent* GetDiscoveryAgent(); @@ -35,13 +43,22 @@ void GetProperty(const char* property, uint32* value); int GetDiscoverable(); - BString GetBluetoothAddress(); - /* + bdaddr_t GetBluetoothAddress(); + /* ServiceRecord getRecord(Connection notifier); void updateRecord(ServiceRecord srvRecord); - */ + */ private: - LocalDevice(); + LocalDevice(hci_id hid); + + static status_t SRetrieveBluetoothMessenger(void); + status_t RetrieveBluetoothMessenger(void); + static LocalDevice* RequestLocalDeviceID(BMessage* request); + + static BMessenger* sfMessenger; + BMessenger* fMessenger; + + hci_id hid; }; } Added: haiku/trunk/headers/os/bluetooth/bluetooth_util.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth_util.h 2008-02-01 20:59:14 UTC (rev 23815) +++ haiku/trunk/headers/os/bluetooth/bluetooth_util.h 2008-02-01 21:17:02 UTC (rev 23816) @@ -0,0 +1,58 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BLUETOOTH_UTIL_H +#define _BLUETOOTH_UTIL_H + +#include + +/* BD Address management */ +static inline int bacmp(bdaddr_t* ba1, bdaddr_t* ba2) +{ + return memcmp(ba1, ba2, sizeof(bdaddr_t)); +} + + +static inline void bacpy(bdaddr_t* dst, bdaddr_t* src) +{ + memcpy(dst, src, sizeof(bdaddr_t)); +} + + +static inline void baswap(bdaddr_t* dst, bdaddr_t* src) { + +} + + +static inline char* batostr(bdaddr_t *ba) +{ + return "00:00:00:00:00:00"; + +} + + +static inline void strtoba(const char *str, bdaddr_t *ba) +{ + +} + + +/* Link key Management */ +static inline char* lktostr( uint8 link_key[16] ) +{ + return "00:00:00:00:00:00"; +} + + +/* TODO: Bluetooth Errors */ [... truncated: 8 lines follow ...] From oruizdorantes at mail.berlios.de Fri Feb 1 22:24:17 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 1 Feb 2008 22:24:17 +0100 Subject: [Haiku-commits] r23817 - haiku/trunk/src/kits/bluetooth Message-ID: <200802012124.m11LOHgJ010274@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-01 22:24:17 +0100 (Fri, 01 Feb 2008) New Revision: 23817 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23817&view=rev Modified: haiku/trunk/src/kits/bluetooth/DiscoveryListener.cpp haiku/trunk/src/kits/bluetooth/Jamfile haiku/trunk/src/kits/bluetooth/LocalDevice.cpp Log: Update LocalDevice class with basic bluetooth_server comunication. Server code still to come. Nothing except the driver tested at the moment... I hope after these nothing is broken Modified: haiku/trunk/src/kits/bluetooth/DiscoveryListener.cpp =================================================================== --- haiku/trunk/src/kits/bluetooth/DiscoveryListener.cpp 2008-02-01 21:17:02 UTC (rev 23816) +++ haiku/trunk/src/kits/bluetooth/DiscoveryListener.cpp 2008-02-01 21:24:17 UTC (rev 23817) @@ -52,7 +52,7 @@ case B_BT_INQUIRY_DEVICE_MSG: /* TODO: Extract info from BMessage to create a - proper RemoteDevice, ???message should be passed from Agent??? */ + proper RemoteDevice, message should be passed from Agent??? */ /* - Instance to be stored/Registered in the Agent? */ //DeviceDiscovered( RemoteDevice(BString("00:00:00:00:00:00")), DeviceClass(0)); Modified: haiku/trunk/src/kits/bluetooth/Jamfile =================================================================== --- haiku/trunk/src/kits/bluetooth/Jamfile 2008-02-01 21:17:02 UTC (rev 23816) +++ haiku/trunk/src/kits/bluetooth/Jamfile 2008-02-01 21:24:17 UTC (rev 23817) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src kits bluetooth ; +UsePrivateHeaders bluetooth ; + SharedLibrary libbluetooth.so : LocalDevice.cpp DiscoveryListener.cpp Modified: haiku/trunk/src/kits/bluetooth/LocalDevice.cpp =================================================================== --- haiku/trunk/src/kits/bluetooth/LocalDevice.cpp 2008-02-01 21:17:02 UTC (rev 23816) +++ haiku/trunk/src/kits/bluetooth/LocalDevice.cpp 2008-02-01 21:24:17 UTC (rev 23817) @@ -5,123 +5,225 @@ * */ - #include +#include #include #include -#include #include +#include "bluetoothserver_p.h" + namespace Bluetooth { +BMessenger* LocalDevice::sfMessenger = NULL; - LocalDevice* - LocalDevice::GetLocalDevice() - { - - return NULL; - } - - - LocalDevice* - LocalDevice::GetLocalDevice(uint8 dev) - { - - return NULL; - - } - - - LocalDevice* - LocalDevice::GetLocalDevice(bdaddr_t bdaddr) - { - - return NULL; +status_t +LocalDevice::SRetrieveBluetoothMessenger(void) +{ + if (sfMessenger == NULL || !sfMessenger->IsValid() ) + sfMessenger = new BMessenger(); + + return (sfMessenger != NULL)?B_OK:B_ERROR; +} + +status_t LocalDevice::RetrieveBluetoothMessenger(void) +{ + if (fMessenger == NULL || !fMessenger->IsValid()) + fMessenger = new BMessenger(); + + return (fMessenger != NULL)?B_OK:B_ERROR; +} + +LocalDevice* +LocalDevice::RequestLocalDeviceID(BMessage* request) +{ + BMessage reply; + hci_id hid; + + if (sfMessenger->SendMessage(request, &reply) == B_OK && + reply.FindInt32("hci_id", &hid) == B_OK ){ + + if (hid > 0) + return new LocalDevice(hid); + } + + return NULL; +} + + +#if 0 +#pragma - +#endif + + +LocalDevice* +LocalDevice::GetLocalDevice() +{ + if (SRetrieveBluetoothMessenger() != B_OK) + return NULL; + + BMessage request(BT_MSG_ADQUIRE_LOCAL_DEVICE); + + return RequestLocalDeviceID(&request); +} + + +LocalDevice* +LocalDevice::GetLocalDevice(hci_id hid) +{ + if (SRetrieveBluetoothMessenger() != B_OK) + return NULL; + + BMessage request(BT_MSG_ADQUIRE_LOCAL_DEVICE); + request.AddInt32("hci_id", hid); + + return RequestLocalDeviceID(&request); + +} + + +LocalDevice* +LocalDevice::GetLocalDevice(bdaddr_t bdaddr) +{ + if (SRetrieveBluetoothMessenger() != B_OK) + return NULL; + + BMessage request(BT_MSG_ADQUIRE_LOCAL_DEVICE); + request.AddData("bdaddr", B_ANY_TYPE, &bdaddr, sizeof(bdaddr_t)); + + + return RequestLocalDeviceID(&request); +} + + +uint32 +LocalDevice::GetLocalDeviceCount() +{ + if (SRetrieveBluetoothMessenger() != B_OK) + return NULL; + + BMessage request(BT_MSG_COUNT_LOCAL_DEVICES); + BMessage reply; + + if (sfMessenger->SendMessage(&request, &reply) == B_OK) + return reply.FindInt32("count"); + else + return B_ERROR; - } +} + + +DiscoveryAgent* +LocalDevice::GetDiscoveryAgent() +{ + + return NULL; +} + + +BString +LocalDevice::GetFriendlyName() +{ + if (RetrieveBluetoothMessenger() != B_OK) + return NULL; + + BString friendlyname; + BMessage request(BT_MSG_GET_FRIENDLY_NAME); + BMessage reply; + + /* ADD ID */ + request.AddInt32("hci_id", hid); + + if (fMessenger->SendMessage(&request, &reply) == B_OK && + reply.FindString("friendlyname", &friendlyname) == B_OK ){ + + return friendlyname; + } - - DiscoveryAgent* - LocalDevice::GetDiscoveryAgent() - { - - return NULL; - } - - - BString - LocalDevice::GetFriendlyName() - { - - return NULL; - } - - - DeviceClass - LocalDevice::GetDeviceClass() - { - - return NULL; - } - - - bool - LocalDevice::SetDiscoverable(int mode) - { - - return false; - } - - - BString - LocalDevice::GetProperty(const char* property) - { - - return NULL; - - } - - - void - LocalDevice::GetProperty(const char* property, uint32* value) - { - - *value = 0; - } - - - int - LocalDevice::GetDiscoverable() - { - - return 0; - } - - - BString - LocalDevice::GetBluetoothAddress() - { - - return NULL; - } - - - /* - ServiceRecord - LocalDevice::getRecord(Connection notifier) { - - } - - void - LocalDevice::updateRecord(ServiceRecord srvRecord) { - - } - */ - LocalDevice::LocalDevice() - { - - } + return BString("Unknown"); +} +DeviceClass +LocalDevice::GetDeviceClass() +{ + + return NULL; } + + +bool +LocalDevice::SetDiscoverable(int mode) +{ + + return false; +} + + +BString +LocalDevice::GetProperty(const char* property) +{ + + return NULL; + +} + + +void +LocalDevice::GetProperty(const char* property, uint32* value) +{ + + *value = 0; +} + + +int +LocalDevice::GetDiscoverable() +{ + + return 0; +} + + +bdaddr_t +LocalDevice::GetBluetoothAddress() +{ + if (RetrieveBluetoothMessenger() != B_OK) + return bdaddrUtils::NullAddress(); + + bdaddr_t bdaddr; + BMessage request(BT_MSG_GET_ADDRESS); + BMessage reply; + ssize_t size; + /* ADD ID */ + request.AddInt32("hci_id", hid); + + if (fMessenger->SendMessage(&request, &reply) == B_OK && + reply.FindData("bdaddr", B_ANY_TYPE, 0, (const void**)&bdaddr, &size) == B_OK ){ + + return bdaddr; + } + + return bdaddrUtils::NullAddress(); +} + + +/* +ServiceRecord +LocalDevice::getRecord(Connection notifier) { + +} + +void +LocalDevice::updateRecord(ServiceRecord srvRecord) { + +} +*/ +LocalDevice::LocalDevice(hci_id hid) : hid(hid) +{ + +} + + +} From bonefish at mail.berlios.de Fri Feb 1 22:46:10 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 1 Feb 2008 22:46:10 +0100 Subject: [Haiku-commits] r23818 - haiku/trunk/build/jam Message-ID: <200802012146.m11LkAmC012018@sheep.berlios.de> Author: bonefish Date: 2008-02-01 22:46:09 +0100 (Fri, 01 Feb 2008) New Revision: 23818 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23818&view=rev Modified: haiku/trunk/build/jam/UserBuildConfig.sample Log: * Added complete list of config variables. * Added explicit example for enabling debugging for a subtree. Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2008-02-01 21:24:17 UTC (rev 23817) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2008-02-01 21:46:09 UTC (rev 23818) @@ -2,15 +2,33 @@ # If existent it is included by the build system, but it is ignored by svn. # This file documents a few examples, what can be done. + # Adjusting Build Variables +# The following variables can be configured per subdirectory (or subtree) or +# even per object file: +# +# CCFLAGS C++FLAGS DEBUG DEFINES HDRS LINKFLAGS OPTIM OPTIMIZE SYSHDRS +# WARNINGS +# HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS +# TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS +# PLATFORM SUPPORTED_PLATFORMS +# +# The following examples would work analogously for any of these variables. + # Turn off warnings in directory src/system/kernel. As fourth (scope) parameter # "local" is specified, which means, that this setting applies only to the # given directory, but not any of its subdirectories. SetConfigVar WARNINGS : HAIKU_TOP src system kernel : 0 : local ; +# Set the debug level for directory src/system/boot/loader and recursively all +# of its subdirectories (scope is "global") to 1. All affected generated files +# will be put into another subtree of the "generated" directory, which allows +# for fast switching between normal and debug builds. +SetConfigVar DEBUG : HAIKU_TOP src system boot loader : 1 : global ; + # Add "RUN_WITHOUT_REGISTRAR" to the DEFINES for the directory src/kits and -# all its subdirectories (scope is "global"). +# all of its subdirectories. AppendToConfigVar DEFINES : HAIKU_TOP src kits : RUN_WITHOUT_REGISTRAR : global ; @@ -18,7 +36,8 @@ # the object file must be specified) to 1. It is worth mentioning, that the # executable the object file is linked into (gdb), will still be placed in # generated/objects/.../release/... Only when setting DEBUG for the executable, -# too, it will be placed in .../debug_1/... +# too, it will be placed in .../debug_1/.... Apart from that, the DEBUG variable +# has no effect on executables or other shared objects. DEBUG on haiku-nat.o = 1 ; From mmlr at mail.berlios.de Fri Feb 1 22:49:28 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Fri, 1 Feb 2008 22:49:28 +0100 Subject: [Haiku-commits] r23819 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda Message-ID: <200802012149.m11LnSHg012220@sheep.berlios.de> Author: mmlr Date: 2008-02-01 22:49:28 +0100 (Fri, 01 Feb 2008) New Revision: 23819 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23819&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c Log: Only put B_PCI_MODULE_NAME if we succeeded in getting the module. Fixes booting on non-PCI systems (i.e. QEMU with -M isapc). Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c 2008-02-01 21:46:09 UTC (rev 23818) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c 2008-02-01 21:49:28 UTC (rev 23819) @@ -24,9 +24,10 @@ return B_OK; } } + + put_module(B_PCI_MODULE_NAME); } - put_module(B_PCI_MODULE_NAME); pci = NULL; return ENODEV; From axeld at mail.berlios.de Sat Feb 2 00:05:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 00:05:27 +0100 Subject: [Haiku-commits] r23820 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200802012305.m11N5RO9018299@sheep.berlios.de> Author: axeld Date: 2008-02-02 00:05:26 +0100 (Sat, 02 Feb 2008) New Revision: 23820 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23820&view=rev Modified: haiku/trunk/headers/private/kernel/lock.h haiku/trunk/src/system/kernel/lock.c Log: Benaphores are nice and fast, but they aren't useful for debugging at all. Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2008-02-01 21:49:28 UTC (rev 23819) +++ haiku/trunk/headers/private/kernel/lock.h 2008-02-01 23:05:26 UTC (rev 23820) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -81,20 +81,28 @@ static inline status_t benaphore_lock(benaphore *ben) { +#ifdef KDEBUG + return acquire_sem(ben->sem); +#else if (atomic_add(&ben->count, -1) <= 0) return acquire_sem(ben->sem); return B_OK; +#endif } static inline status_t benaphore_unlock(benaphore *ben) { +#ifdef KDEBUG + release_sem(ben->sem); +#else if (atomic_add(&ben->count, 1) < 0) return release_sem(ben->sem); return B_OK; +#endif } extern status_t rw_lock_init(rw_lock *lock, const char *name); Modified: haiku/trunk/src/system/kernel/lock.c =================================================================== --- haiku/trunk/src/system/kernel/lock.c 2008-02-01 21:49:28 UTC (rev 23819) +++ haiku/trunk/src/system/kernel/lock.c 2008-02-01 23:05:26 UTC (rev 23820) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -202,7 +202,11 @@ return B_BAD_VALUE; ben->count = 1; +#ifdef KDEBUG + ben->sem = create_sem(1, name); +#else ben->sem = create_sem(0, name); +#endif if (ben->sem >= B_OK) return B_OK; From bga at mail.berlios.de Sat Feb 2 00:24:11 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sat, 2 Feb 2008 00:24:11 +0100 Subject: [Haiku-commits] r23821 - haiku/trunk/headers/private/kernel Message-ID: <200802012324.m11NOB6o020590@sheep.berlios.de> Author: bga Date: 2008-02-02 00:24:10 +0100 (Sat, 02 Feb 2008) New Revision: 23821 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23821&view=rev Modified: haiku/trunk/headers/private/kernel/lock.h Log: It is a good idea to return a value. :) Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2008-02-01 23:05:26 UTC (rev 23820) +++ haiku/trunk/headers/private/kernel/lock.h 2008-02-01 23:24:10 UTC (rev 23821) @@ -96,7 +96,7 @@ benaphore_unlock(benaphore *ben) { #ifdef KDEBUG - release_sem(ben->sem); + return release_sem(ben->sem); #else if (atomic_add(&ben->count, 1) < 0) return release_sem(ben->sem); From superstippi at gmx.de Sat Feb 2 10:49:30 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 02 Feb 2008 10:49:30 +0100 Subject: [Haiku-commits] r23812 - haiku/trunk/src/apps/drivesetup In-Reply-To: <47A367AE.5070401@bug-br.org.br> References: <200802011802.m11I25dG012679@sheep.berlios.de> <47A367AE.5070401@bug-br.org.br> Message-ID: <20080202104930.693.1@stippis2.1201945136.fake> Bruno Albuquerque wrote (2008-02-01, 19:40:46 [+0100]): > stippi at BerliOS wrote: > > Author: stippi > > Date: 2008-02-01 19:02:04 +0100 (Fri, 01 Feb 2008) New Revision: 23812 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23812&view=rev > > > > Modified: > > haiku/trunk/src/apps/drivesetup/DiskView.cpp > > haiku/trunk/src/apps/drivesetup/MainWindow.cpp > > Log: > > * To be able to call BPartition::GetPartitioningIngo(), you need to call > > I know that Ingo did most of the partitioning stuff but, isn't it going > way too far? ;) Hehe. Sorry, Ingo... that was really unintentional! But it's indeed a frequent typo I have to correct. It's driving me nuts sometimes... Best regards, -Stephan From axeld at mail.berlios.de Sat Feb 2 13:12:55 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 13:12:55 +0100 Subject: [Haiku-commits] r23822 - in haiku/trunk: headers/private/kernel/slab src/system/kernel/slab Message-ID: <200802021212.m12CCtBb003784@sheep.berlios.de> Author: axeld Date: 2008-02-02 13:12:54 +0100 (Sat, 02 Feb 2008) New Revision: 23822 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23822&view=rev Modified: haiku/trunk/headers/private/kernel/slab/Depot.h haiku/trunk/src/system/kernel/slab/Slab.cpp Log: * Temporarily switched to a recursive lock for the depot. * While this is not a really good idea for a lock with supposedly little contention, but it'll fix bug #1731. I haven't tested it yet, but will do so in a minute :-) * I will need to rework the slab anyway so that it's possible to use it as a replacement for our heap, and then I'll switch back to a benaphore again. Modified: haiku/trunk/headers/private/kernel/slab/Depot.h =================================================================== --- haiku/trunk/headers/private/kernel/slab/Depot.h 2008-02-01 23:24:10 UTC (rev 23821) +++ haiku/trunk/headers/private/kernel/slab/Depot.h 2008-02-02 12:12:54 UTC (rev 23822) @@ -1,22 +1,17 @@ /* * Copyright 2007, Hugo Santos. All Rights Reserved. * Distributed under the terms of the MIT License. - * - * Authors: - * Hugo Santos, hugosantos at gmail.com */ #ifndef _SLAB_DEPOT_H_ #define _SLAB_DEPOT_H_ + #include #include -#ifdef __cplusplus -extern "C" { -#endif typedef struct object_depot { - benaphore lock; + recursive_lock lock; struct depot_magazine *full, *empty; size_t full_count, empty_count; struct depot_cpu_store *stores; @@ -25,8 +20,12 @@ } object_depot; +#ifdef __cplusplus +extern "C" { +#endif + status_t object_depot_init(object_depot *depot, uint32 flags, - void (*return_object)(object_depot *, void *)); + void (*returnObject)(object_depot *, void *)); void object_depot_destroy(object_depot *depot); void *object_depot_obtain(object_depot *depot); @@ -38,4 +37,4 @@ } #endif -#endif +#endif /* _SLAB_DEPOT_H_ */ Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-02-01 23:24:10 UTC (rev 23821) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-02-02 12:12:54 UTC (rev 23822) @@ -1,10 +1,8 @@ /* * Copyright 2008, Axel D?rfler. All Rights Reserved. * Copyright 2007, Hugo Santos. All Rights Reserved. + * * Distributed under the terms of the MIT License. - * - * Authors: - * Hugo Santos, hugosantos at gmail.com */ @@ -254,6 +252,20 @@ static status_t +recursive_lock_boot_init(recursive_lock *lock, const char *name, uint32 flags) +{ + if (flags & CACHE_DURING_BOOT) { + lock->sem = -1; + lock->holder = 1; + lock->recursion = 0; + return B_OK; + } + + return recursive_lock_init(lock, name); +} + + +static status_t benaphore_boot_init(benaphore *lock, const char *name, uint32 flags) { if (flags & CACHE_DURING_BOOT) { @@ -1021,7 +1033,7 @@ static bool exchange_with_full(object_depot *depot, depot_magazine* &magazine) { - BenaphoreLocker _(depot->lock); + RecursiveLocker _(depot->lock); if (depot->full == NULL) return false; @@ -1038,7 +1050,7 @@ static bool exchange_with_empty(object_depot *depot, depot_magazine* &magazine) { - BenaphoreLocker _(depot->lock); + RecursiveLocker _(depot->lock); if (depot->empty == NULL) { depot->empty = alloc_magazine(); @@ -1097,14 +1109,14 @@ depot->empty = NULL; depot->full_count = depot->empty_count = 0; - status_t status = benaphore_boot_init(&depot->lock, "depot", flags); + status_t status = recursive_lock_boot_init(&depot->lock, "depot", flags); if (status < B_OK) return status; depot->stores = (depot_cpu_store *)internal_alloc(sizeof(depot_cpu_store) * smp_get_num_cpus(), flags); if (depot->stores == NULL) { - benaphore_destroy(&depot->lock); + recursive_lock_destroy(&depot->lock); return B_NO_MEMORY; } @@ -1122,7 +1134,7 @@ status_t object_depot_init_locks(object_depot *depot) { - status_t status = benaphore_init(&depot->lock, "depot"); + status_t status = recursive_lock_init(&depot->lock, "depot"); if (status < B_OK) return status; @@ -1147,7 +1159,7 @@ internal_free(depot->stores); - benaphore_destroy(&depot->lock); + recursive_lock_destroy(&depot->lock); } @@ -1233,7 +1245,7 @@ depot->stores[i].loaded = depot->stores[i].previous = NULL; } - BenaphoreLocker _(depot->lock); + RecursiveLocker _(depot->lock); while (depot->full) empty_magazine(depot, _pop(depot->full)); From axeld at mail.berlios.de Sat Feb 2 13:18:57 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 13:18:57 +0100 Subject: [Haiku-commits] r23823 - in haiku/trunk: headers/build src/add-ons/kernel/bus_managers/agp_gart Message-ID: <200802021218.m12CIvmg024988@sheep.berlios.de> Author: axeld Date: 2008-02-02 13:18:55 +0100 (Sat, 02 Feb 2008) New Revision: 23823 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23823&view=rev Modified: haiku/trunk/headers/build/HaikuBuildCompatibility.h haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp Log: * Added B_NOT_SUPPORTED, B_KERNEL_READ_AREA, and B_KERNEL_WRITE_AREA to HaikuBuildCompatibility.h; this fixes building agp_gart and the intel extreme driver for BeOS. * Added sockaddr_storage to HaikuBuildCompatibility.h. Modified: haiku/trunk/headers/build/HaikuBuildCompatibility.h =================================================================== --- haiku/trunk/headers/build/HaikuBuildCompatibility.h 2008-02-02 12:12:54 UTC (rev 23822) +++ haiku/trunk/headers/build/HaikuBuildCompatibility.h 2008-02-02 12:18:55 UTC (rev 23823) @@ -24,6 +24,14 @@ typedef unsigned long haiku_build_addr_t; #define addr_t haiku_build_addr_t +struct sockaddr_storage { + uint8 ss_len; /* total length */ + uint8 ss_family; /* address family */ + uint8 __ss_pad1[6]; /* align to quad */ + uint64 __ss_pad2; /* force alignment to 64 bit */ + uint8 __ss_pad3[112]; /* pad to a total of 128 bytes */ +}; + typedef int socklen_t; #ifndef DEFFILEMODE @@ -131,6 +139,8 @@ # define B_VECTOR_ICON_TYPE 'VICN' # endif # define B_NOT_SUPPORTED (B_ERROR) +# define B_KERNEL_READ_AREA 0 +# define B_KERNEL_WRITE_AREA 0 #endif #if defined(HAIKU_TARGET_PLATFORM_BONE) || defined(HAIKU_TARGET_PLATFORM_DANO) Modified: haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp 2008-02-02 12:12:54 UTC (rev 23822) +++ haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp 2008-02-02 12:18:55 UTC (rev 23823) @@ -43,7 +43,6 @@ # define PCI_capabilities_ptr 0x34 # define PCI_status_capabilities 0x0010 # define PCI_cap_id_agp 0x02 -# define B_NOT_SUPPORTED B_ERROR #endif #define TRACE_AGP @@ -629,8 +628,8 @@ TRACE("bind %ld bytes at %lx\n", size, base); for (addr_t offset = 0; offset < size; offset += B_PAGE_SIZE) { + addr_t physicalAddress = 0; status_t status; - addr_t physicalAddress; if (!physical) { physical_entry entry; From stippi at mail.berlios.de Sat Feb 2 13:38:16 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Feb 2008 13:38:16 +0100 Subject: [Haiku-commits] r23824 - in haiku/trunk: headers/private/storage src/kits/storage/disk_device Message-ID: <200802021238.m12CcGaS030223@sheep.berlios.de> Author: stippi Date: 2008-02-02 13:38:15 +0100 (Sat, 02 Feb 2008) New Revision: 23824 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23824&view=rev Modified: haiku/trunk/headers/private/storage/PartitioningInfo.h haiku/trunk/src/kits/storage/disk_device/PartitioningInfo.cpp Log: * added a PrintToStream() method * added optional tracing for the main operations * fixed bad pointer arithmetic when reallocating/moving the object's data * it was impossible to remove the very first space via _RemoveSpaces() * added a little more variaty to error return codes for some functions to make them a little more helpful -> This fixes the bogus space values in DriveSetup (#1737) Modified: haiku/trunk/headers/private/storage/PartitioningInfo.h =================================================================== --- haiku/trunk/headers/private/storage/PartitioningInfo.h 2008-02-02 12:18:55 UTC (rev 23823) +++ haiku/trunk/headers/private/storage/PartitioningInfo.h 2008-02-02 12:38:15 UTC (rev 23824) @@ -28,6 +28,7 @@ off_t* offset, off_t*size) const; int32 CountPartitionableSpaces() const; + void PrintToStream() const; private: status_t _InsertSpaces(int32 index, int32 count); void _RemoveSpaces(int32 index, int32 count); Modified: haiku/trunk/src/kits/storage/disk_device/PartitioningInfo.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/PartitioningInfo.cpp 2008-02-02 12:18:55 UTC (rev 23823) +++ haiku/trunk/src/kits/storage/disk_device/PartitioningInfo.cpp 2008-02-02 12:38:15 UTC (rev 23824) @@ -3,6 +3,7 @@ // by the OpenBeOS license. //--------------------------------------------------------------------- +#include #include #include @@ -16,6 +17,14 @@ using namespace std; +//#define TRACING 1 +#if TRACING +# define TRACE(x) printf x +#else +# define TRACE(x) +#endif + + // constructor BPartitioningInfo::BPartitioningInfo() : fPartitionID(-1), @@ -37,6 +46,8 @@ status_t BPartitioningInfo::SetTo(off_t offset, off_t size) { + TRACE(("%p - BPartitioningInfo::SetTo(offset = %lld, size = %lld)\n", this, offset, size)); + fPartitionID = -1; delete[] fSpaces; @@ -78,6 +89,9 @@ if (size <= 0) return B_OK; + TRACE(("%p - BPartitioningInfo::ExcludeOccupiedSpace(offset = %lld, " + "size = %lld)\n", this, offset, size)); + int32 leftIndex = -1; int32 rightIndex = -1; for (int32 i = 0; i < fCount; i++) { @@ -90,6 +104,8 @@ rightIndex = i; } + TRACE((" leftIndex = %ld, rightIndex = %ld\n", leftIndex, rightIndex)); + // If there's no intersection with any free space, we're done. if (leftIndex == -1 || rightIndex == -1 || leftIndex > rightIndex) return B_OK; @@ -102,11 +118,18 @@ // special case: split a single space in two if (leftIndex == rightIndex && leftSpace.offset < offset && rightSpaceEnd > offset + size) { + + TRACE((" splitting space at %ld\n", leftIndex)); + // add a space after this one status_t error = _InsertSpaces(leftIndex + 1, 1); if (error != B_OK) return error; + // IMPORTANT: after calling _InsertSpace(), one can not + // use the partitionable_space_data references "leftSpace" + // and "rightSpace" anymore (declared above)! + partitionable_space_data& space = fSpaces[leftIndex]; partitionable_space_data& newSpace = fSpaces[leftIndex + 1]; @@ -115,6 +138,9 @@ newSpace.offset = offset + size; newSpace.size = rightSpaceEnd - newSpace.offset; + #ifdef TRACING + PrintToStream(); + #endif return B_OK; } @@ -122,6 +148,9 @@ int32 deleteFirst = leftIndex; if (leftSpace.offset < offset) { leftSpace.size = offset - leftSpace.offset; + + TRACE((" left space remains, new size is %lld\n", leftSpace.size)); + deleteFirst++; } @@ -130,6 +159,10 @@ if (rightSpaceEnd > offset + size) { rightSpace.offset = offset + size; rightSpace.size = rightSpaceEnd - rightSpace.offset; + + TRACE((" right space remains, new offset = %lld, size = %lld\n", + rightSpace.offset, rightSpace.size)); + deleteLast--; } @@ -137,6 +170,9 @@ if (deleteFirst <= deleteLast) _RemoveSpaces(deleteFirst, deleteLast - deleteFirst + 1); + #ifdef TRACING + PrintToStream(); + #endif return B_OK; } @@ -154,8 +190,12 @@ BPartitioningInfo::GetPartitionableSpaceAt(int32 index, off_t *offset, off_t *size) const { - if (!fSpaces || !offset || !size || index < 0 || index >= fCount) + if (!fSpaces) + return B_NO_INIT; + if (!offset || !size) return B_BAD_VALUE; + if (index < 0 || index >= fCount) + return B_BAD_INDEX; *offset = fSpaces[index].offset; *size = fSpaces[index].size; return B_OK; @@ -170,6 +210,25 @@ } +// PrintToStream +void +BPartitioningInfo::PrintToStream() const +{ + if (!fSpaces) { + printf("BPartitioningInfo is not initialized\n"); + return; + } + printf("BPartitioningInfo has %ld spaces:\n", fCount); + for (int32 i = 0; i < fCount; i++) { + printf(" space at %ld: offset = %lld, size = %lld\n", + i, fSpaces[i].offset, fSpaces[i].size); + } +} + + +// #pragma mark - + + // _InsertSpaces status_t BPartitioningInfo::_InsertSpaces(int32 index, int32 count) @@ -180,7 +239,8 @@ // If the capacity is sufficient, we just need to copy the spaces to create // a gap. if (fCount + count <= fCapacity) { - memmove(fSpaces + index + count, fSpaces + index, fCount - index); + memmove(fSpaces + index + count, fSpaces + index, + (fCount - index) * sizeof(partitionable_space_data)); fCount += count; return B_OK; } @@ -195,8 +255,9 @@ return B_NO_MEMORY; // copy items - memcpy(spaces, fSpaces, index); - memcpy(spaces + index + count, fSpaces + index, fCount - index); + memcpy(spaces, fSpaces, index * sizeof(partitionable_space_data)); + memcpy(spaces + index + count, fSpaces + index, + (fCount - index) * sizeof(partitionable_space_data)); delete[] fSpaces; fSpaces = spaces; @@ -211,12 +272,13 @@ void BPartitioningInfo::_RemoveSpaces(int32 index, int32 count) { - if (index <= 0 || count <= 0 || index + count > fCount) + if (index < 0 || count <= 0 || index + count > fCount) return; if (count < fCount) { int32 endIndex = index + count; - memmove(fSpaces + index, fSpaces + endIndex, fCount - endIndex); + memmove(fSpaces + index, fSpaces + endIndex, + (fCount - endIndex) * sizeof(partitionable_space_data)); } fCount -= count; From axeld at mail.berlios.de Sat Feb 2 15:20:34 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 15:20:34 +0100 Subject: [Haiku-commits] r23825 - haiku/trunk/src/system/kernel/slab Message-ID: <200802021420.m12EKYfL005394@sheep.berlios.de> Author: axeld Date: 2008-02-02 15:20:33 +0100 (Sat, 02 Feb 2008) New Revision: 23825 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23825&view=rev Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp Log: * Also replaced the cpu store's lock with a recursive lock in order to fix bug #1731. * However, it turns out that depot destruction obviously doesn't work correctly, at least we keep partial or full slabs around when we're using them (which causes the code to panic). * Therefore, I've now disabled depots completely, until I find the time to really work on that code. Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-02-02 12:38:15 UTC (rev 23824) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-02-02 14:20:33 UTC (rev 23825) @@ -153,7 +153,7 @@ struct depot_cpu_store { - benaphore lock; + recursive_lock lock; struct depot_magazine *loaded, *previous; }; @@ -443,8 +443,9 @@ cache->flags = flags; + // TODO: depot destruction is obviously broken // no gain in using the depot in single cpu setups - if (smp_get_num_cpus() == 1) + //if (smp_get_num_cpus() == 1) cache->flags |= CACHE_NO_DEPOT; if (!(cache->flags & CACHE_NO_DEPOT)) { @@ -645,7 +646,6 @@ void * object_cache_alloc(object_cache *cache, uint32 flags) { - // flags are read only. if (!(cache->flags & CACHE_NO_DEPOT)) { void *object = object_depot_obtain(&cache->depot); if (object) @@ -724,7 +724,6 @@ if (object == NULL) return; - // flags are read only. if (!(cache->flags & CACHE_NO_DEPOT)) { if (object_depot_store(&cache->depot, object)) return; @@ -1121,7 +1120,7 @@ } for (int i = 0; i < smp_get_num_cpus(); i++) { - benaphore_boot_init(&depot->stores[i].lock, "cpu store", flags); + recursive_lock_boot_init(&depot->stores[i].lock, "cpu store", flags); depot->stores[i].loaded = depot->stores[i].previous = NULL; } @@ -1139,7 +1138,7 @@ return status; for (int i = 0; i < smp_get_num_cpus(); i++) { - status = benaphore_init(&depot->stores[i].lock, "cpu store"); + status = recursive_lock_init(&depot->stores[i].lock, "cpu store"); if (status < B_OK) return status; } @@ -1154,7 +1153,7 @@ object_depot_make_empty(depot); for (int i = 0; i < smp_get_num_cpus(); i++) { - benaphore_destroy(&depot->stores[i].lock); + recursive_lock_destroy(&depot->stores[i].lock); } internal_free(depot->stores); @@ -1166,7 +1165,7 @@ static void * object_depot_obtain_from_store(object_depot *depot, depot_cpu_store *store) { - BenaphoreLocker _(store->lock); + RecursiveLocker _(store->lock); // To better understand both the Alloc() and Free() logic refer to // Bonwick's ``Magazines and Vmem'' [in 2001 USENIX proceedings] @@ -1195,7 +1194,7 @@ object_depot_return_to_store(object_depot *depot, depot_cpu_store *store, void *object) { - BenaphoreLocker _(store->lock); + RecursiveLocker _(store->lock); // We try to add the object to the loaded magazine if we have one // and it's not full, or to the previous one if it is empty. If @@ -1236,7 +1235,7 @@ for (int i = 0; i < smp_get_num_cpus(); i++) { depot_cpu_store *store = &depot->stores[i]; - BenaphoreLocker _(store->lock); + RecursiveLocker _(store->lock); if (depot->stores[i].loaded) empty_magazine(depot, depot->stores[i].loaded); From axeld at mail.berlios.de Sat Feb 2 18:32:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 18:32:03 +0100 Subject: [Haiku-commits] r23826 - in haiku/trunk/headers/posix: . sys Message-ID: <200802021732.m12HW31L024102@sheep.berlios.de> Author: axeld Date: 2008-02-02 18:32:01 +0100 (Sat, 02 Feb 2008) New Revision: 23826 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23826&view=rev Modified: haiku/trunk/headers/posix/grp.h haiku/trunk/headers/posix/limits.h haiku/trunk/headers/posix/sys/select.h haiku/trunk/headers/posix/syslog.h Log: * Added BSD's FD_COPY() macro (it's not POSIX, though). * Some other minor improvements. Modified: haiku/trunk/headers/posix/grp.h =================================================================== --- haiku/trunk/headers/posix/grp.h 2008-02-02 14:20:33 UTC (rev 23825) +++ haiku/trunk/headers/posix/grp.h 2008-02-02 17:32:01 UTC (rev 23826) @@ -1,8 +1,9 @@ +/* + * Copyright 2004-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _GRP_H_ #define _GRP_H_ -/* -** Distributed under the terms of the Haiku License. -*/ #include @@ -11,7 +12,7 @@ struct group { char *gr_name; char *gr_passwd; - int gr_gid; + gid_t gr_gid; char **gr_mem; }; Modified: haiku/trunk/headers/posix/limits.h =================================================================== --- haiku/trunk/headers/posix/limits.h 2008-02-02 14:20:33 UTC (rev 23825) +++ haiku/trunk/headers/posix/limits.h 2008-02-02 17:32:01 UTC (rev 23826) @@ -25,12 +25,13 @@ /* These are various BeOS implementation limits */ #define ARG_MAX (32768) -#define ATEXIT_MAX (32) /* XXXdbg */ +#define ATEXIT_MAX (32) #define CHILD_MAX (1024) #define IOV_MAX (1024) #define FILESIZEBITS (64) +#define LINE_MAX (2048) #define LINK_MAX (1) -#define LOGIN_NAME_MAX (32) /* XXXdbg */ +#define LOGIN_NAME_MAX (32) #define MAX_CANON (255) #define MAX_INPUT (255) #define NAME_MAX (256) @@ -47,7 +48,7 @@ #define _POSIX_ARG_MAX (32768) #define _POSIX_CHILD_MAX (1024) #define _POSIX_LINK_MAX (1) -#define _POSIX_LOGIN_NAME_MAX (9) /* XXXdbg */ +#define _POSIX_LOGIN_NAME_MAX (9) #define _POSIX_MAX_CANON (255) #define _POSIX_MAX_INPUT (255) #define _POSIX_NAME_MAX (255) @@ -60,4 +61,6 @@ #define _POSIX_TTY_NAME_MAX (256) #define _POSIX_TZNAME_MAX (3) +#define _POSIX2_LINE_MAX (2048) + #endif /* _LIBC_LIMITS_H_ */ Modified: haiku/trunk/headers/posix/sys/select.h =================================================================== --- haiku/trunk/headers/posix/sys/select.h 2008-02-02 14:20:33 UTC (rev 23825) +++ haiku/trunk/headers/posix/sys/select.h 2008-02-02 17:32:01 UTC (rev 23826) @@ -41,6 +41,7 @@ #define FD_SET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] |= _FD_BIT(fd)) #define FD_CLR(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] &= ~_FD_BIT(fd)) #define FD_ISSET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] & _FD_BIT(fd)) +#define FD_COPY(source, target) (*(target) = *(source)) #endif /* FD_SET */ Modified: haiku/trunk/headers/posix/syslog.h =================================================================== --- haiku/trunk/headers/posix/syslog.h 2008-02-02 14:20:33 UTC (rev 23825) +++ haiku/trunk/headers/posix/syslog.h 2008-02-02 17:32:01 UTC (rev 23826) @@ -1,11 +1,12 @@ -/* -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _SYSLOG_H_ #define _SYSLOG_H_ -/*** options for openlog() ***/ +/* options for openlog() */ #define LOG_PID (1 << 12) /* log the process (thread/team) ID with each message */ #define LOG_CONS (2 << 12) /* log to the system console on error */ @@ -16,7 +17,7 @@ #define LOG_NOWAIT (64 << 12) /* do not wait for child processes */ -/*** facilities ***/ +/* facilities */ #define LOG_KERN (0 << 3) /* messages generated by the kernel */ #define LOG_USER (1 << 3) /* by user processes */ @@ -29,6 +30,7 @@ #define LOG_UUCP (8 << 3) #define LOG_CRON (9 << 3) #define LOG_AUTHPRIV (10 << 3) +#define LOG_FTP (11 << 3) /* these are for local use: */ #define LOG_LOCAL0 (16 << 3) @@ -41,7 +43,7 @@ #define LOG_LOCAL7 (23 << 3) -/*** priorities ***/ +/* priorities */ #define LOG_EMERG 0 /* a panic condition */ #define LOG_PANIC LOG_EMERG @@ -61,13 +63,13 @@ extern "C" { #endif -// POSIX calls +/* POSIX calls */ extern void closelog(void); extern void openlog(const char *ident, int options, int facility); extern int setlogmask(int priorityMask); extern void syslog(int priority, const char *message, ...); -// Be extensions +/* Be extensions */ extern void closelog_team(void); extern void openlog_team(const char *ident, int logopt, int facility); extern void log_team(int priority, const char *message, ...); From axeld at mail.berlios.de Sat Feb 2 18:38:12 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Feb 2008 18:38:12 +0100 Subject: [Haiku-commits] r23827 - in haiku/trunk: headers/compatibility/bsd headers/compatibility/bsd/netinet headers/compatibility/bsd/sys src/libs/bsd Message-ID: <200802021738.m12HcCuG003530@sheep.berlios.de> Author: axeld Date: 2008-02-02 18:38:09 +0100 (Sat, 02 Feb 2008) New Revision: 23827 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23827&view=rev Added: haiku/trunk/headers/compatibility/bsd/netinet/ haiku/trunk/headers/compatibility/bsd/netinet/in_systm.h haiku/trunk/src/libs/bsd/usershell.c Modified: haiku/trunk/headers/compatibility/bsd/libutil.h haiku/trunk/headers/compatibility/bsd/sys/param.h haiku/trunk/headers/compatibility/bsd/unistd.h haiku/trunk/src/libs/bsd/Jamfile Log: Minor improvements for the BSD compatibility library: * Added {get|set|end}usershell() functions. * Define MAXLOGNAME, and L_SET, L_INCR, and L_XTND. * The pidfile stuff in libutil.h is now included, too. Modified: haiku/trunk/headers/compatibility/bsd/libutil.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-02 17:32:01 UTC (rev 23826) +++ haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-02 17:38:09 UTC (rev 23827) @@ -52,15 +52,13 @@ char *value; } *properties; -#ifdef _SYS_PARAM_H_ /* for pidfile.c */ struct pidfh { int pf_fd; char pf_path[MAXPATHLEN + 1]; - __dev_t pf_dev; + dev_t pf_dev; ino_t pf_ino; }; -#endif /* Avoid pulling in all the include files for no need */ struct termios; @@ -120,12 +118,10 @@ int pw_tmp(int _mfd); #endif -#ifdef _SYS_PARAM_H_ struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr); int pidfile_write(struct pidfh *pfh); int pidfile_close(struct pidfh *pfh); int pidfile_remove(struct pidfh *pfh); -#endif __END_DECLS Added: haiku/trunk/headers/compatibility/bsd/netinet/in_systm.h =================================================================== Modified: haiku/trunk/headers/compatibility/bsd/sys/param.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/sys/param.h 2008-02-02 17:32:01 UTC (rev 23826) +++ haiku/trunk/headers/compatibility/bsd/sys/param.h 2008-02-02 17:38:09 UTC (rev 23827) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _BSD_SYS_PARAM_H_ @@ -27,4 +27,8 @@ # define howmany(x, y) (((x) + ((y) - 1)) / (y)) #endif +#ifndef MAXLOGNAME +# define MAXLOGNAME 32 +#endif + #endif /* _BSD_SYS_PARAM_H_ */ Modified: haiku/trunk/headers/compatibility/bsd/unistd.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/unistd.h 2008-02-02 17:32:01 UTC (rev 23826) +++ haiku/trunk/headers/compatibility/bsd/unistd.h 2008-02-02 17:38:09 UTC (rev 23827) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _BSD_UNISTD_H_ @@ -9,12 +9,20 @@ #include_next +#define L_SET SEEK_SET +#define L_INCR SEEK_CUR +#define L_XTND SEEK_END + + #ifdef __cplusplus extern "C" { #endif +void endusershell(void); char *getpass(const char *prompt); +char *getusershell(void); int issetugid(void); +void setusershell(void); #ifdef __cplusplus } Modified: haiku/trunk/src/libs/bsd/Jamfile =================================================================== --- haiku/trunk/src/libs/bsd/Jamfile 2008-02-02 17:32:01 UTC (rev 23826) +++ haiku/trunk/src/libs/bsd/Jamfile 2008-02-02 17:38:09 UTC (rev 23827) @@ -14,5 +14,6 @@ signal.c stringlist.c unvis.c + usershell.c vis.c ; Added: haiku/trunk/src/libs/bsd/usershell.c =================================================================== --- haiku/trunk/src/libs/bsd/usershell.c 2008-02-02 17:32:01 UTC (rev 23826) +++ haiku/trunk/src/libs/bsd/usershell.c 2008-02-02 17:38:09 UTC (rev 23827) @@ -0,0 +1,39 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + */ + + +#include + + +static int sShellIndex; + + +char * +getusershell(void) +{ + if (sShellIndex++ == 0) + return "/bin/sh"; + + return NULL; +} + + +void +endusershell(void) +{ + sShellIndex = 0; +} + + +void +setusershell(void) +{ + sShellIndex = 0; +} + + From bga at mail.berlios.de Sat Feb 2 18:38:56 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sat, 2 Feb 2008 18:38:56 +0100 Subject: [Haiku-commits] r23828 - haiku/trunk/src/kits/storage Message-ID: <200802021738.m12HcuCx004897@sheep.berlios.de> Author: bga Date: 2008-02-02 18:38:55 +0100 (Sat, 02 Feb 2008) New Revision: 23828 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23828&view=rev Modified: haiku/trunk/src/kits/storage/File.cpp Log: ReadAt() should not change the file position. Tested under R5 and Zeta. This fixes bug #1200 (Received emails are missing attributes). I hope nothing relies on the previously broken behaviour. Modified: haiku/trunk/src/kits/storage/File.cpp =================================================================== --- haiku/trunk/src/kits/storage/File.cpp 2008-02-02 17:38:09 UTC (rev 23827) +++ haiku/trunk/src/kits/storage/File.cpp 2008-02-02 17:38:55 UTC (rev 23828) @@ -358,7 +358,13 @@ return InitCheck(); if (location < 0) return B_BAD_VALUE; - return _kern_read(get_fd(), location, buffer, size); + + // ReadAt() is not supposed to move the current position on the file. + // Tested on BeOS R5 and Zeta. + ssize_t result = _kern_read(get_fd(), location, buffer, size); + Seek(-result, SEEK_CUR); // Resets file position. + + return result; } // Write From bga at mail.berlios.de Sat Feb 2 18:59:34 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sat, 2 Feb 2008 18:59:34 +0100 Subject: [Haiku-commits] r23829 - haiku/trunk/src/kits/storage Message-ID: <200802021759.m12HxYwA001794@sheep.berlios.de> Author: bga Date: 2008-02-02 18:59:33 +0100 (Sat, 02 Feb 2008) New Revision: 23829 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23829&view=rev Modified: haiku/trunk/src/kits/storage/File.cpp Log: This fixes my previous fix. The position to read can be completelly random so I have to first cache the current position before calling _kern_read() and reset it afterwards. *NOW* this fixes bug #1200 in all cases. Modified: haiku/trunk/src/kits/storage/File.cpp =================================================================== --- haiku/trunk/src/kits/storage/File.cpp 2008-02-02 17:38:55 UTC (rev 23828) +++ haiku/trunk/src/kits/storage/File.cpp 2008-02-02 17:59:33 UTC (rev 23829) @@ -361,8 +361,9 @@ // ReadAt() is not supposed to move the current position on the file. // Tested on BeOS R5 and Zeta. + off_t curPos = Position(); // Cache current position. ssize_t result = _kern_read(get_fd(), location, buffer, size); - Seek(-result, SEEK_CUR); // Resets file position. + Seek(curPos, SEEK_SET); // Resets file position. return result; } From superstippi at gmx.de Sat Feb 2 19:21:21 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 02 Feb 2008 19:21:21 +0100 Subject: [Haiku-commits] r23829 - haiku/trunk/src/kits/storage In-Reply-To: <200802021759.m12HxYwA001794@sheep.berlios.de> References: <200802021759.m12HxYwA001794@sheep.berlios.de> Message-ID: <20080202192121.1072.2@stippis2.1201974661.fake> bga at BerliOS wrote (2008-02-02, 18:59:34 [+0100]): > Author: bga > Date: 2008-02-02 18:59:33 +0100 (Sat, 02 Feb 2008) New Revision: 23829 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23829&view=rev > > Modified: > haiku/trunk/src/kits/storage/File.cpp > Log: > This fixes my previous fix. The position to read can be completelly > random so I have to first cache the current position before calling > _kern_read() and reset it afterwards. > > *NOW* this fixes bug #1200 in all cases. I was just going to mention that... :-) What about WriteAt() - shouldn't this be synchronous? Have you done the same tests there? Best regards & thanks for the fixes, -Stephan From stippi at mail.berlios.de Sat Feb 2 19:28:26 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Feb 2008 19:28:26 +0100 Subject: [Haiku-commits] r23830 - haiku/trunk/src/kits/storage Message-ID: <200802021828.m12ISQm4013214@sheep.berlios.de> Author: stippi Date: 2008-02-02 19:28:26 +0100 (Sat, 02 Feb 2008) New Revision: 23830 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23830&view=rev Modified: haiku/trunk/src/kits/storage/File.cpp Log: * the BeBook documents WriteAt() and Write() to differ analogous to ReadAt() and Read() with regards to the file position. Ie, WriteAt() is not supposed to modify the data pointer. Modified: haiku/trunk/src/kits/storage/File.cpp =================================================================== --- haiku/trunk/src/kits/storage/File.cpp 2008-02-02 17:59:33 UTC (rev 23829) +++ haiku/trunk/src/kits/storage/File.cpp 2008-02-02 18:28:26 UTC (rev 23830) @@ -398,7 +398,13 @@ return InitCheck(); if (location < 0) return B_BAD_VALUE; - return _kern_write(get_fd(), location, buffer, size); + + // WriteAt() is not supposed to move the current position on the file. + off_t curPos = Position(); // Cache current position. + ssize_t result = _kern_write(get_fd(), location, buffer, size); + Seek(curPos, SEEK_SET); // Resets file position. + + return result; } // Seek From superstippi at gmx.de Sat Feb 2 19:31:31 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 02 Feb 2008 19:31:31 +0100 Subject: [Haiku-commits] r23829 - haiku/trunk/src/kits/storage In-Reply-To: <20080202192121.1072.2@stippis2.1201974661.fake> References: <200802021759.m12HxYwA001794@sheep.berlios.de> <20080202192121.1072.2@stippis2.1201974661.fake> Message-ID: <20080202193131.1328.3@stippis2.1201974661.fake> Stephan Assmus wrote (2008-02-02, 19:21:21 [+0100]): > > bga at BerliOS wrote (2008-02-02, 18:59:34 [+0100]): > > Author: bga > > Date: 2008-02-02 18:59:33 +0100 (Sat, 02 Feb 2008) New Revision: 23829 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23829&view=rev > > > > Modified: > > haiku/trunk/src/kits/storage/File.cpp > > Log: > > This fixes my previous fix. The position to read can be completelly > > random so I have to first cache the current position before calling > > _kern_read() and reset it afterwards. > > > > *NOW* this fixes bug #1200 in all cases. > > I was just going to mention that... :-) What about WriteAt() - shouldn't > this be synchronous? Have you done the same tests there? Update: BeBook says WriteAt() is analogous to ReadAt()... I already commited that... hope that was ok, BGA. Thanks for debugging these problems in the first place! It was always kind of lame to have that bug in Haiku, not being able to properly demonstrate meta data on e-mail and all (by actually downloading some). :-) Best regards, -Stephan From bga at bug-br.org.br Sat Feb 2 19:39:57 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Sat, 02 Feb 2008 16:39:57 -0200 Subject: [Haiku-commits] r23829 - haiku/trunk/src/kits/storage In-Reply-To: <20080202192121.1072.2@stippis2.1201974661.fake> References: <200802021759.m12HxYwA001794@sheep.berlios.de> <20080202192121.1072.2@stippis2.1201974661.fake> Message-ID: <47A4B8FD.7010203@bug-br.org.br> Stephan Assmus escreveu: > I was just going to mention that... :-) What about WriteAt() - shouldn't > this be synchronous? Have you done the same tests there? Yes, you are right. I saw you fixed it yourself so, thanks. :) -Bruno From stippi at mail.berlios.de Sat Feb 2 20:08:58 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Feb 2008 20:08:58 +0100 Subject: [Haiku-commits] r23831 - haiku/trunk/headers/compatibility/bsd Message-ID: <200802021908.m12J8wop016430@sheep.berlios.de> Author: stippi Date: 2008-02-02 20:08:58 +0100 (Sat, 02 Feb 2008) New Revision: 23831 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23831&view=rev Modified: haiku/trunk/headers/compatibility/bsd/libutil.h Log: Include for MAXPATHLEN - fixes the build. Modified: haiku/trunk/headers/compatibility/bsd/libutil.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-02 18:28:26 UTC (rev 23830) +++ haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-02 19:08:58 UTC (rev 23831) @@ -40,6 +40,7 @@ #define _LIBUTIL_H_ #include +#include #include #define PROPERTY_MAX_NAME 64 From axeld at pinc-software.de Sat Feb 2 22:00:54 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 02 Feb 2008 22:00:54 +0100 CET Subject: [Haiku-commits] r23830 - haiku/trunk/src/kits/storage In-Reply-To: <200802021828.m12ISQm4013214@sheep.berlios.de> Message-ID: <34727296530-BeMail@zon> stippi at BerliOS wrote: > Log: > * the BeBook documents WriteAt() and Write() to differ analogous to > ReadAt() and Read() with regards to the file position. Ie, > WriteAt() > is not supposed to modify the data pointer. Actually, both versions aren't really how this should look like. read_pos() and write_pos() are affected, too, BTW. IOW the kernel's read/write functions should be fixed, I'm going to do that unless someone beats me. Bye, Axel. From axeld at pinc-software.de Sat Feb 2 22:03:33 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 02 Feb 2008 22:03:33 +0100 CET Subject: [Haiku-commits] r23831 - haiku/trunk/headers/compatibility/bsd In-Reply-To: <200802021908.m12J8wop016430@sheep.berlios.de> Message-ID: <34886122368-BeMail@zon> stippi at BerliOS wrote: > Log: > Include for MAXPATHLEN - fixes the build. Thanks, I missed that one! Bye, Axel. From axeld at mail.berlios.de Sun Feb 3 00:50:52 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 00:50:52 +0100 Subject: [Haiku-commits] r23832 - in haiku/trunk/src: kits/storage system/kernel/fs Message-ID: <200802022350.m12NoqHJ004790@sheep.berlios.de> Author: axeld Date: 2008-02-03 00:50:51 +0100 (Sun, 03 Feb 2008) New Revision: 23832 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23832&view=rev Modified: haiku/trunk/src/kits/storage/File.cpp haiku/trunk/src/system/kernel/fs/fd.cpp Log: * Fixed _{kern|user}_{read|write}[v]() functions to not move the descriptor's file position in case an offset was specified. * Reverted r23828-r23830 in File.cpp: don't fix the symptoms but the cause of the problem (hey, that has to be in the kernel, right? :)) * Cleanup of File.cpp, removed OpenBeOS namespace. * Moved user_fd_kernel_ioctl() to the section where it belongs to (that function should be renamed, though). Modified: haiku/trunk/src/kits/storage/File.cpp =================================================================== --- haiku/trunk/src/kits/storage/File.cpp 2008-02-02 19:08:58 UTC (rev 23831) +++ haiku/trunk/src/kits/storage/File.cpp 2008-02-02 23:50:51 UTC (rev 23832) @@ -1,12 +1,13 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -//--------------------------------------------------------------------- -/*! - \file File.cpp - BFile implementation. -*/ +/* + * Copyright 2002-2008, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Tyler Dauwalder + * Ingo Weinhold, bonefish at users.sf.net + */ + #include #include @@ -22,11 +23,6 @@ // declared in sys/umask.c -#ifdef USE_OPENBEOS_NAMESPACE -namespace OpenBeOS { -#endif - -// constructor //! Creates an uninitialized BFile. BFile::BFile() : BNode(), @@ -35,7 +31,7 @@ { } -// copy constructor + //! Creates a copy of the supplied BFile. /*! If \a file is uninitialized, the newly constructed BFile will be, too. \param file the BFile object to be copied @@ -48,7 +44,7 @@ *this = file; } -// constructor + /*! \brief Creates a BFile and initializes it to the file referred to by the supplied entry_ref and according to the specified open mode. \param ref the entry_ref referring to the file @@ -63,7 +59,7 @@ SetTo(ref, openMode); } -// constructor + /*! \brief Creates a BFile and initializes it to the file referred to by the supplied BEntry and according to the specified open mode. \param entry the BEntry referring to the file @@ -78,7 +74,7 @@ SetTo(entry, openMode); } -// constructor + /*! \brief Creates a BFile and initializes it to the file referred to by the supplied path name and according to the specified open mode. \param path the file's path name @@ -93,7 +89,7 @@ SetTo(path, openMode); } -// constructor + /*! \brief Creates a BFile and initializes it to the file referred to by the supplied path name relative to the specified BDirectory and according to the specified open mode. @@ -111,9 +107,9 @@ SetTo(dir, path, openMode); } -// destructor -//! Frees all allocated resources. -/*! If the file is properly initialized, the file's file descriptor is closed. + +/*! \brief Frees all allocated resources. + If the file is properly initialized, the file's file descriptor is closed. */ BFile::~BFile() { @@ -125,7 +121,7 @@ close_fd(); } -// SetTo + /*! \brief Re-initializes the BFile to the file referred to by the supplied entry_ref and according to the specified open mode. \param ref the entry_ref referring to the file @@ -175,7 +171,7 @@ return fCStatus; } -// SetTo + /*! \brief Re-initializes the BFile to the file referred to by the supplied BEntry and according to the specified open mode. \param entry the BEntry referring to the file @@ -218,7 +214,7 @@ return fCStatus; } -// SetTo + /*! \brief Re-initializes the BFile to the file referred to by the supplied path name and according to the specified open mode. \param path the file's path name @@ -256,7 +252,7 @@ return fCStatus; } -// SetTo + /*! \brief Re-initializes the BFile to the file referred to by the supplied path name relative to the specified BDirectory and according to the specified open mode. @@ -298,9 +294,9 @@ return fCStatus; } -// IsReadable -//! Returns whether the file is readable. -/*! \return + +/*! \brief Returns whether the file is readable. + \return - \c true, if the BFile has been initialized properly and the file has been been opened for reading, - \c false, otherwise. @@ -308,14 +304,13 @@ bool BFile::IsReadable() const { - return (InitCheck() == B_OK - && ((fMode & O_RWMASK) == O_RDONLY - || (fMode & O_RWMASK) == O_RDWR)); + return InitCheck() == B_OK + && ((fMode & O_RWMASK) == O_RDONLY || (fMode & O_RWMASK) == O_RDWR); } -// IsWritable -//! Returns whether the file is writable. -/*! \return + +/*! \brief Returns whether the file is writable. + \return - \c true, if the BFile has been initialized properly and the file has been opened for writing, - \c false, otherwise. @@ -323,14 +318,13 @@ bool BFile::IsWritable() const { - return (InitCheck() == B_OK - && ((fMode & O_RWMASK) == O_WRONLY - || (fMode & O_RWMASK) == O_RDWR)); + return InitCheck() == B_OK + && ((fMode & O_RWMASK) == O_WRONLY || (fMode & O_RWMASK) == O_RDWR); } -// Read -//! Reads a number of bytes from the file into a buffer. -/*! \param buffer the buffer the data from the file shall be written to + +/*! \brief Reads a number of bytes from the file into a buffer. + \param buffer the buffer the data from the file shall be written to \param size the number of bytes that shall be read \return the number of bytes actually read or an error code */ @@ -342,7 +336,7 @@ return _kern_read(get_fd(), -1, buffer, size); } -// ReadAt + /*! \brief Reads a number of bytes from a certain position within the file into a buffer. \param location the position (in bytes) within the file from which the @@ -359,18 +353,12 @@ if (location < 0) return B_BAD_VALUE; - // ReadAt() is not supposed to move the current position on the file. - // Tested on BeOS R5 and Zeta. - off_t curPos = Position(); // Cache current position. - ssize_t result = _kern_read(get_fd(), location, buffer, size); - Seek(curPos, SEEK_SET); // Resets file position. - - return result; + return _kern_read(get_fd(), location, buffer, size); } -// Write -//! Writes a number of bytes from a buffer into the file. -/*! \param buffer the buffer containing the data to be written to the file + +/*! \brief Writes a number of bytes from a buffer into the file. + \param buffer the buffer containing the data to be written to the file \param size the number of bytes that shall be written \return the number of bytes actually written or an error code */ @@ -382,7 +370,7 @@ return _kern_write(get_fd(), -1, buffer, size); } -// WriteAt + /*! \brief Writes a number of bytes from a buffer at a certain position into the file. \param location the position (in bytes) within the file at which the data @@ -399,17 +387,12 @@ if (location < 0) return B_BAD_VALUE; - // WriteAt() is not supposed to move the current position on the file. - off_t curPos = Position(); // Cache current position. - ssize_t result = _kern_write(get_fd(), location, buffer, size); - Seek(curPos, SEEK_SET); // Resets file position. - - return result; + return _kern_write(get_fd(), location, buffer, size); } -// Seek -//! Seeks to another read/write position within the file. -/*! It is allowed to seek past the end of the file. A subsequent call to + +/*! \brief Seeks to another read/write position within the file. + It is allowed to seek past the end of the file. A subsequent call to Write() will pad the file with undefined data. Seeking before the beginning of the file will fail and the behavior of subsequent Read() or Write() invocations will be undefined. @@ -432,9 +415,9 @@ return _kern_seek(get_fd(), offset, seekMode); } -// Position -//! Returns the current read/write position within the file. -/*! \return + +/*! \brief Returns the current read/write position within the file. + \return - the current read/write position relative to the beginning of the file - \c B_ERROR, after a Seek() before the beginning of the file - \c B_FILE_ERROR, if the file has not been initialized @@ -447,9 +430,9 @@ return _kern_seek(get_fd(), 0, SEEK_CUR); } -// SetSize -//! Sets the size of the file. -/*! If the file is shorter than \a size bytes it will be padded with + +/*! \brief Sets the size of the file. + If the file is shorter than \a size bytes it will be padded with unspecified data to the requested size. If it is larger, it will be truncated. Note: There's no problem with setting the size of a BFile opened in @@ -473,16 +456,16 @@ return set_stat(statData, B_STAT_SIZE); } -// GetSize TODO: doxygen comment + status_t BFile::GetSize(off_t* size) const { return BStatable::GetSize(size); } -// = -//! Assigns another BFile to this BFile. -/*! If the other BFile is uninitialized, this one will be too. Otherwise it + +/*! \brief Assigns another BFile to this BFile. + If the other BFile is uninitialized, this one will be too. Otherwise it will refer to the same file using the same mode, unless an error occurs. \param file the original BFile \return a reference to this BFile @@ -517,7 +500,6 @@ void BFile::_PhiloFile6() {} -// get_fd /*! Returns the file descriptor. To be used instead of accessing the BNode's private \c fFd member directly. \return the file descriptor, or -1, if not properly initialized. @@ -528,7 +510,7 @@ return fFd; } -// close_fd + /*! Overrides BNode::close_fd() solely for R5 binary compatibility. */ void @@ -537,8 +519,3 @@ BNode::close_fd(); } - -#ifdef USE_OPENBEOS_NAMESPACE -}; // namespace OpenBeOS -#endif - Modified: haiku/trunk/src/system/kernel/fs/fd.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fd.cpp 2008-02-02 19:08:58 UTC (rev 23831) +++ haiku/trunk/src/system/kernel/fs/fd.cpp 2008-02-02 23:50:51 UTC (rev 23832) @@ -1,9 +1,10 @@ -/* Operations on file descriptors - * - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ +//! Operations on file descriptors + #include #include @@ -611,10 +612,18 @@ } -// #pragma mark - -// User syscalls +status_t +user_fd_kernel_ioctl(int fd, ulong op, void *buffer, size_t length) +{ + TRACE(("user_fd_kernel_ioctl: fd %d\n", fd)); + return fd_ioctl(false, fd, op, buffer, length); +} + +// #pragma mark - User syscalls + + ssize_t _user_read(int fd, off_t pos, void *buffer, size_t length) { @@ -636,8 +645,11 @@ return B_FILE_ERROR; } - if (pos == -1) + bool movePosition = false; + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_read) { bytesRead = descriptor->ops->fd_read(descriptor, pos, buffer, &length); @@ -647,7 +659,8 @@ else bytesRead = (ssize_t)length; - descriptor->pos = pos + length; + if (movePosition) + descriptor->pos = pos + length; } } else bytesRead = B_BAD_VALUE; @@ -661,6 +674,7 @@ _user_readv(int fd, off_t pos, const iovec *userVecs, size_t count) { struct file_descriptor *descriptor; + bool movePosition = false; ssize_t bytesRead = 0; status_t status; iovec *vecs; @@ -696,8 +710,10 @@ goto err2; } - if (pos == -1) + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_read) { for (i = 0; i < count; i++) { @@ -719,7 +735,8 @@ bytesRead = B_BAD_VALUE; status = bytesRead; - descriptor->pos = pos; + if (movePosition) + descriptor->pos = pos; err2: free(vecs); @@ -749,8 +766,11 @@ return B_FILE_ERROR; } - if (pos == -1) + bool movePosition = false; + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_write) { bytesWritten = descriptor->ops->fd_write(descriptor, pos, buffer, &length); @@ -760,7 +780,8 @@ else bytesWritten = (ssize_t)length; - descriptor->pos = pos + length; + if (movePosition) + descriptor->pos = pos + length; } } else bytesWritten = B_BAD_VALUE; @@ -774,6 +795,7 @@ _user_writev(int fd, off_t pos, const iovec *userVecs, size_t count) { struct file_descriptor *descriptor; + bool movePosition = false; ssize_t bytesWritten = 0; status_t status; iovec *vecs; @@ -809,8 +831,10 @@ goto err2; } - if (pos == -1) + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_write) { for (i = 0; i < count; i++) { @@ -832,7 +856,8 @@ bytesWritten = B_BAD_VALUE; status = bytesWritten; - descriptor->pos = pos; + if (movePosition) + descriptor->pos = pos; err2: free(vecs); @@ -951,8 +976,7 @@ } -// #pragma mark - -// Kernel calls +// #pragma mark - Kernel calls ssize_t @@ -972,8 +996,11 @@ return B_FILE_ERROR; } - if (pos == -1) + bool movePosition = false; + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_read) { bytesRead = descriptor->ops->fd_read(descriptor, pos, buffer, &length); @@ -983,7 +1010,8 @@ else bytesRead = (ssize_t)length; - descriptor->pos = pos + length; + if (movePosition) + descriptor->pos = pos + length; } } else bytesRead = B_BAD_VALUE; @@ -997,6 +1025,7 @@ _kern_readv(int fd, off_t pos, const iovec *vecs, size_t count) { struct file_descriptor *descriptor; + bool movePosition = false; ssize_t bytesRead = 0; status_t status; uint32 i; @@ -1012,13 +1041,16 @@ return B_FILE_ERROR; } - if (pos == -1) + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_read) { for (i = 0; i < count; i++) { size_t length = vecs[i].iov_len; - status = descriptor->ops->fd_read(descriptor, pos, vecs[i].iov_base, &length); + status = descriptor->ops->fd_read(descriptor, pos, vecs[i].iov_base, + &length); if (status < B_OK) { bytesRead = status; break; @@ -1034,7 +1066,9 @@ } else bytesRead = B_BAD_VALUE; - descriptor->pos = pos; + if (movePosition) + descriptor->pos = pos; + put_fd(descriptor); return bytesRead; } @@ -1057,18 +1091,23 @@ return B_FILE_ERROR; } - if (pos == -1) + bool movePosition = false; + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_write) { - bytesWritten = descriptor->ops->fd_write(descriptor, pos, buffer, &length); + bytesWritten = descriptor->ops->fd_write(descriptor, pos, buffer, + &length); if (bytesWritten >= B_OK) { if (length > SSIZE_MAX) bytesWritten = SSIZE_MAX; else bytesWritten = (ssize_t)length; - descriptor->pos = pos + length; + if (movePosition) + descriptor->pos = pos + length; } } else bytesWritten = B_BAD_VALUE; @@ -1082,6 +1121,7 @@ _kern_writev(int fd, off_t pos, const iovec *vecs, size_t count) { struct file_descriptor *descriptor; + bool movePosition = false; ssize_t bytesWritten = 0; status_t status; uint32 i; @@ -1097,13 +1137,16 @@ return B_FILE_ERROR; } - if (pos == -1) + if (pos == -1) { pos = descriptor->pos; + movePosition = true; + } if (descriptor->ops->fd_write) { for (i = 0; i < count; i++) { size_t length = vecs[i].iov_len; - status = descriptor->ops->fd_write(descriptor, pos, vecs[i].iov_base, &length); + status = descriptor->ops->fd_write(descriptor, pos, + vecs[i].iov_base, &length); if (status < B_OK) { bytesWritten = status; break; @@ -1119,7 +1162,9 @@ } else bytesWritten = B_BAD_VALUE; - descriptor->pos = pos; + if (movePosition) + descriptor->pos = pos; + put_fd(descriptor); return bytesWritten; } @@ -1153,15 +1198,6 @@ } -status_t -user_fd_kernel_ioctl(int fd, ulong op, void *buffer, size_t length) -{ - TRACE(("user_fd_kernel_ioctl: fd %d\n", fd)); - - return fd_ioctl(false, fd, op, buffer, length); -} - - ssize_t _kern_read_dir(int fd, struct dirent *buffer, size_t bufferSize, uint32 maxCount) { From revol at free.fr Sun Feb 3 01:16:09 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 03 Feb 2008 01:16:09 +0100 CET Subject: [Haiku-commits] r23830 - haiku/trunk/src/kits/storage In-Reply-To: <34727296530-BeMail@zon> Message-ID: <597755277-BeMail@laptop> > stippi at BerliOS wrote: > > Log: > > * the BeBook documents WriteAt() and Write() to differ analogous to > > ReadAt() and Read() with regards to the file position. Ie, > > WriteAt() > > is not supposed to modify the data pointer. > > Actually, both versions aren't really how this should look like. > read_pos() and write_pos() are affected, too, BTW. Which is what ReadAt and WriteAt should be using instead of resetting the file pointer! > IOW the kernel's read/write functions should be fixed, I'm going to > do > that unless someone beats me. Go ahead :) Fran?ois. From revol at free.fr Sun Feb 3 01:21:22 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 03 Feb 2008 01:21:22 +0100 CET Subject: [Haiku-commits] r23830 - haiku/trunk/src/kits/storage In-Reply-To: <597755277-BeMail@laptop> Message-ID: <910546144-BeMail@laptop> > > stippi at BerliOS wrote: > > > Log: > > > * the BeBook documents WriteAt() and Write() to differ analogous > > > to > > > ReadAt() and Read() with regards to the file position. Ie, > > > WriteAt() > > > is not supposed to modify the data pointer. > > > > Actually, both versions aren't really how this should look like. > > read_pos() and write_pos() are affected, too, BTW. > > Which is what ReadAt and WriteAt should be using instead of resetting > the file pointer! Forget it, I read read() (:p) instead of _kern_read(). > > > IOW the kernel's read/write functions should be fixed, I'm going to > > do > > that unless someone beats me. > > Go ahead :) > Looks like it's done already :) Fran?ois. From marcusoverhagen at arcor.de Sun Feb 3 02:06:53 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Sun, 3 Feb 2008 02:06:53 +0100 (CET) Subject: [Haiku-commits] r23828 - haiku/trunk/src/kits/storage In-Reply-To: <200802021738.m12HcuCx004897@sheep.berlios.de> References: <200802021738.m12HcuCx004897@sheep.berlios.de> Message-ID: <20148599.1202000813257.JavaMail.ngmail@webmail10> > ReadAt() should not change the file position. Tested under R5 and Zeta. This > fixes bug #1200 (Received emails are > missing attributes). > + ssize_t result = _kern_read(get_fd(), location, buffer, size); > + Seek(-result, SEEK_CUR); // Resets file position. This isn't save, and should directly be done in the kernel, without seek. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From mmu_man at mail.berlios.de Sun Feb 3 12:39:31 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 12:39:31 +0100 Subject: [Haiku-commits] r23833 - in haiku/trunk: headers/private/kernel/arch/m68k src/system/kernel/arch/m68k Message-ID: <200802031139.m13BdV4v012991@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 12:39:28 +0100 (Sun, 03 Feb 2008) New Revision: 23833 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23833&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h haiku/trunk/headers/private/kernel/arch/m68k/arch_int.h haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp Log: * get rid of ppc stuff * possible types of exception frames Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h 2008-02-02 23:50:51 UTC (rev 23832) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_cpu.h 2008-02-03 11:39:28 UTC (rev 23833) @@ -12,65 +12,201 @@ #define PAGE_SIZE 4096 -#warning M68K: check for missing regs/movem -struct iframe { - /* XXX: order depends on movem */ - uint32 d0; - uint32 d1; - uint32 d2; - uint32 d3; - uint32 d4; - uint32 d5; - uint32 d6; - uint32 d7; - uint32 a0; - uint32 a1; - uint32 a2; - uint32 a3; - uint32 a4; - uint32 a5; - uint32 a6; - uint32 a7; - /* 030 ex frame: */ - uint16 sr; /* contains ccr */ - uint32 pc; - uint16 vector; /* [12:15] frame type */ - /* other stuff depending on frame type... do we really need that ? */ +/* 68k has many different possible stack frames, differentiated by a 4 bit number, + * but they also depend on the cpu type. + * cf. mint/sys/arch/check_exc.h + */ + +/* definitions for special status word */ + +// 020 as well +struct mc68030_ssw { + uint16 fc:1; + uint16 fb:1; + uint16 rc:1; + uint16 rb:1; + uint16 :3; + uint16 df:1; + uint16 rm:1; + uint16 rw:1; + uint16 size:2; + uint16 :1; + uint16 as:3; +} _PACKED; + +struct mc68040_ssw { + uint16 cp:1; + uint16 cu:1; + uint16 ct:1; + uint16 cm:1; + uint16 ma:1; + uint16 atc:1; + uint16 lk:1; + uint16 rw:1; + uint16 :1; + uint16 size:2; + uint16 tt:2; + uint16 tm:3; +} _PACKED; + +struct mc68060_fslw { + uint32 :4; + uint32 ma:1; + uint32 :1; + uint32 lk:1; + uint32 rw:2; //XXX ?? + uint32 size:2; + uint32 tt:2; + uint32 tm:2; + uint32 io:1; + uint32 pbe:1; + uint32 sbe:1; + uint32 pta:1; + uint32 ptb:1; + uint32 il:1; + uint32 pf:1; + uint32 sb:1; + uint32 wp:1; + uint32 twe:1; + uint32 re:1; + uint32 we:1; + uint32 ttr:1; + uint32 bpe:1; + uint32 :1; + uint32 see:1; +} _PACKED; + +/* raw exception frames */ + +struct mc680x0_type_0_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; +}; + +struct mc680x0_type_1_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; +}; + +struct mc680x0_type_2_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t instruction_address; +}; + +struct mc680x0_type_3_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t effective_address; +}; + +struct mc68040_type_7_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t effective_address; + struct mc68040_ssw ssw; + // write-back status + uint16 wb3s; + uint16 wb2s; + uint16 wb1s; + addr_t fault_address; + addr_t wb3a; + uint32 wb3d; + addr_t wb2a; + uint32 wb2d; + addr_t wb1a; + uint32 wb1d; // also pd0 + uint32 pd1; + uint32 pd2; + uint32 pd3; +}; + +struct mc680x0_type_9_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t instruction_address; + uint16 intregs[4]; +}; + +struct mc68030_type_a_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + uint16 intreg1; + struct mc68030_ssw ssw; + uint16 instpipe_c; + uint16 instpipe_b; + addr_t fault_address; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[2]; +}; + +struct mc68030_type_b_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + uint16 intreg1; + struct mc68030_ssw ssw; + uint16 instpipe_c; + uint16 instpipe_b; + addr_t fault_address; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[4]; + uint32 stbaddr; + uint16 intregs4[2]; + uint32 datain; + uint16 intregs5[3]; + uint16 intinfo; + uint16 intregs6[18]; +}; + +//XXX: add 060 frames + +struct mc680x0_frame { union { struct { - uint32 inst; - } format2 _PACKED; - struct { - uint32 inst; - uint16 intregs[4]; - } format9 _PACKED; - struct { - uint16 intregs[1]; - uint16 ssw; - uint16 instpipe_c; - uint16 instpipe_b; - uint32 faultaddr; - uint16 intregs2[2]; - uint32 dataout; - uint16 intregs3[2]; - } formata _PACKED; - struct { - uint16 intregs[1]; - uint16 ssw; - uint16 instpipe_c; - uint16 instpipe_b; - uint32 faultaddr; - uint16 intregs2[2]; - uint32 dataout; - uint16 intregs3[4]; - uint32 stbaddr; - uint16 intregs4[2]; - uint32 datain; - uint16 intregs5[3]; - uint16 intinfo; - uint16 intregs6[18]; - } formatb _PACKED; + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + }; + struct mc680x0_type_0_frame type_0; + struct mc680x0_type_1_frame type_1; + struct mc680x0_type_2_frame type_2; + struct mc68040_type_7_frame type_7; + struct mc680x0_type_9_frame type_9; + struct mc68030_type_a_frame type_a; + struct mc68030_type_b_frame type_b; + // XXX: add 060 frames }; +}; + +#warning M68K: check for missing regs/movem +struct iframe { + // XXX: fp_frame ? + /* data and address registers */ + // XXX: order depends on movem + uint32 d[8]; + uint32 a[7]; + /* cpu exception frame, including sr, pc, format and vector */ + struct mc680x0_frame cpu; + /* uint32 vector; uint32 srr0; uint32 srr1; Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_int.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_int.h 2008-02-02 23:50:51 UTC (rev 23832) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_int.h 2008-02-03 11:39:28 UTC (rev 23833) @@ -13,34 +13,4 @@ #define NUM_IO_VECTORS 256 -/* The sprg0 register of each CPU points to the physical address of such - a structure. So it is at hand in the early exception handling code. -*/ -struct m68k_cpu_exception_context { - void *kernel_handle_exception; // exception handler routine in the - // kernel - void *exception_context; // the virtual address of this - // structure - void *kernel_stack; // kernel stack for the current thread - - uint32 scratch[8]; // scratch memory for free use in the - // early exception handling code -}; - -#ifdef __cplusplus -extern "C" { -#endif - - -struct m68k_cpu_exception_context *m68k_get_cpu_exception_context(int cpu); - -void m68k_set_current_cpu_exception_context( - struct m68k_cpu_exception_context *context); - // only called once per CPU - - -#ifdef __cplusplus -} -#endif - #endif /* _KERNEL_ARCH_M68K_INT_H */ Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp 2008-02-02 23:50:51 UTC (rev 23832) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp 2008-02-03 11:39:28 UTC (rev 23833) @@ -39,10 +39,6 @@ extern"C" void m68k_exception_tail(void); -// the exception contexts for all CPUs -static m68k_cpu_exception_context sCPUExceptionContexts[SMP_MAX_CPUS]; - - // An iframe stack used in the early boot process when we don't have // threads yet. struct iframe_stack gBootFrameStack; @@ -82,13 +78,13 @@ { dprintf("iframe at %p:\n", frame); dprintf(" d0 0x%08lx d1 0x%08lx d2 0x%08lx d3 0x%08lx\n", - frame->d0, frame->d1, frame->d2, frame->d3); + frame->d[0], frame->d[1], frame->d[2], frame->d[3]); kprintf(" d4 0x%08lx d5 0x%08lx d6 0x%08lx d7 0x%08lx\n", - frame->d4, frame->d5, frame->d6, frame->d7); + frame->d[4], frame->d[5], frame->d[6], frame->d[7]); kprintf(" a0 0x%08lx a1 0x%08lx a2 0x%08lx a3 0x%08lx\n", - frame->a0, frame->a1, frame->a2, frame->a3); - kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx a7 0x%08lx (sp)\n", - frame->d4, frame->d5, frame->d6, frame->d7); + frame->a[0], frame->a[1], frame->a[2], frame->a[3]); + kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx "/*"a7 0x%08lx (sp)"*/"\n", + frame->a[4], frame->a[5], frame->a[6]/*, frame->a[7]*/); /*kprintf(" pc 0x%08lx ccr 0x%02x\n", frame->pc, frame->ccr);*/ From korli at mail.berlios.de Sun Feb 3 14:01:42 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 3 Feb 2008 14:01:42 +0100 Subject: [Haiku-commits] r23834 - in haiku/trunk/src/add-ons/translators: . exr exr/openexr exr/openexr/config exr/openexr/half exr/openexr/iex exr/openexr/ilmimf exr/openexr/ilmthread exr/openexr/imath Message-ID: <200802031301.m13D1gOu018803@sheep.berlios.de> Author: korli Date: 2008-02-03 14:01:23 +0100 (Sun, 03 Feb 2008) New Revision: 23834 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23834&view=rev Added: haiku/trunk/src/add-ons/translators/exr/ haiku/trunk/src/add-ons/translators/exr/ConfigView.cpp haiku/trunk/src/add-ons/translators/exr/ConfigView.h haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp haiku/trunk/src/add-ons/translators/exr/EXRGamma.h haiku/trunk/src/add-ons/translators/exr/EXRTranslator.cpp haiku/trunk/src/add-ons/translators/exr/EXRTranslator.h haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h haiku/trunk/src/add-ons/translators/exr/Jamfile haiku/trunk/src/add-ons/translators/exr/main.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ haiku/trunk/src/add-ons/translators/exr/openexr/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/config/ haiku/trunk/src/add-ons/translators/exr/openexr/config/IlmBaseConfig.h haiku/trunk/src/add-ons/translators/exr/openexr/config/OpenEXRConfig.h haiku/trunk/src/add-ons/translators/exr/openexr/exrheader.cpp haiku/trunk/src/add-ons/translators/exr/openexr/half/ haiku/trunk/src/add-ons/translators/exr/openexr/half/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/half/eLut.cpp haiku/trunk/src/add-ons/translators/exr/openexr/half/eLut.h haiku/trunk/src/add-ons/translators/exr/openexr/half/half.cpp haiku/trunk/src/add-ons/translators/exr/openexr/half/half.h haiku/trunk/src/add-ons/translators/exr/openexr/half/halfFunction.h haiku/trunk/src/add-ons/translators/exr/openexr/half/halfLimits.h haiku/trunk/src/add-ons/translators/exr/openexr/half/toFloat.cpp haiku/trunk/src/add-ons/translators/exr/openexr/half/toFloat.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/ haiku/trunk/src/add-ons/translators/exr/openexr/iex/Iex.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexBaseExc.cpp haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexBaseExc.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexErrnoExc.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexMacros.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexMathExc.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexThrowErrnoExc.cpp haiku/trunk/src/add-ons/translators/exr/openexr/iex/IexThrowErrnoExc.h haiku/trunk/src/add-ons/translators/exr/openexr/iex/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfArray.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfAutoArray.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfB44Compressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfB44Compressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfBoxAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfBoxAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCRgbaFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCRgbaFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChannelList.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChannelList.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChannelListAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChannelListAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChromaticities.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChromaticities.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChromaticitiesAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfChromaticitiesAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCompression.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCompressionAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCompressionAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCompressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfCompressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfConvert.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfConvert.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfDoubleAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfDoubleAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfEnvmap.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfEnvmap.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfEnvmapAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfEnvmapAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFloatAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFloatAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFrameBuffer.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFrameBuffer.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFramesPerSecond.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfFramesPerSecond.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfHeader.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfHeader.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfHuf.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfHuf.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfIO.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfIO.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfInputFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfInputFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfInt64.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfIntAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfIntAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfKeyCode.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfKeyCode.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfKeyCodeAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfKeyCodeAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfLineOrder.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfLineOrderAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfLineOrderAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfLut.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfLut.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfMatrixAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfMatrixAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfMisc.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfMisc.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfName.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfOpaqueAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfOpaqueAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfOutputFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfOutputFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPixelType.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPizCompressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPizCompressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPreviewImage.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPreviewImage.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPreviewImageAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPreviewImageAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPxr24Compressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfPxr24Compressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRational.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRational.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRationalAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRationalAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRgba.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRgbaFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRgbaFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRgbaYca.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRgbaYca.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRleCompressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfRleCompressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfScanLineInputFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfScanLineInputFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStandardAttributes.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStandardAttributes.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStdIO.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStdIO.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStringAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfStringAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTestFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTestFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfThreading.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfThreading.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTileDescription.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTileDescriptionAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTileDescriptionAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTileOffsets.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTileOffsets.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledInputFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledInputFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledMisc.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledMisc.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledOutputFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledOutputFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledRgbaFile.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTiledRgbaFile.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTimeCode.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTimeCode.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTimeCodeAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfTimeCodeAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfVecAttribute.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfVecAttribute.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfVersion.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfVersion.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfWav.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfWav.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfXdr.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfZipCompressor.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/ImfZipCompressor.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/b44ExpLogTable.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/b44ExpLogTable.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/ haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThread.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThread.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadMutex.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadMutex.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadMutexPosix.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadMutexWin32.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadPool.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadPool.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadPosix.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadSemaphore.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadSemaphore.h haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadSemaphorePosix.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadSemaphorePosixCompat.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadSemaphoreWin32.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/IlmThreadWin32.cpp haiku/trunk/src/add-ons/translators/exr/openexr/ilmthread/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/imath/ haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathBox.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathBox.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathBoxAlgo.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathColor.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathColorAlgo.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathColorAlgo.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathEuler.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathExc.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathFrame.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathFrustum.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathFun.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathFun.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathGL.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathGLU.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathHalfLimits.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathInt64.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathInterval.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathLimits.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathLine.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathLineAlgo.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathMath.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathMatrix.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathMatrixAlgo.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathMatrixAlgo.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathPlane.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathPlatform.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathQuat.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathRandom.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathRandom.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathRoots.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathShear.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathShear.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathSphere.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathVec.cpp haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathVec.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/ImathVecAlgo.h haiku/trunk/src/add-ons/translators/exr/openexr/imath/Jamfile Modified: haiku/trunk/src/add-ons/translators/Jamfile Log: added a translator for EXR images, based on www.openexr.com This builds only with GCC 4, mostly because it needs libstdc++ v3 Modified: haiku/trunk/src/add-ons/translators/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/Jamfile 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/Jamfile 2008-02-03 13:01:23 UTC (rev 23834) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons translators ; SubInclude HAIKU_TOP src add-ons translators bmp ; +SubInclude HAIKU_TOP src add-ons translators exr ; SubInclude HAIKU_TOP src add-ons translators gif ; SubInclude HAIKU_TOP src add-ons translators hpgs ; SubInclude HAIKU_TOP src add-ons translators ico ; Added: haiku/trunk/src/add-ons/translators/exr/ConfigView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/ConfigView.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/ConfigView.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,68 @@ +/* + * Copyright 2008, J?r?me Duval. All rights reserved. + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "ConfigView.h" +#include "EXRTranslator.h" + +#include +#include + +#include +#include + + +ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) + : BView(frame, "EXRTranslator Settings", resize, flags) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + + font_height fontHeight; + be_bold_font->GetHeight(&fontHeight); + float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + + BRect rect(10, 10, 200, 10 + height); + BStringView *stringView = new BStringView(rect, "title", "EXR Images"); + stringView->SetFont(be_bold_font); + stringView->ResizeToPreferred(); + AddChild(stringView); + + rect.OffsetBy(0, height + 10); + char version[256]; + sprintf(version, "Version %d.%d.%d, %s", + int(B_TRANSLATION_MAJOR_VERSION(EXR_TRANSLATOR_VERSION)), + int(B_TRANSLATION_MINOR_VERSION(EXR_TRANSLATOR_VERSION)), + int(B_TRANSLATION_REVISION_VERSION(EXR_TRANSLATOR_VERSION)), + __DATE__); + stringView = new BStringView(rect, "version", version); + stringView->ResizeToPreferred(); + AddChild(stringView); + + GetFontHeight(&fontHeight); + height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + + rect.OffsetBy(0, height + 5); + stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); + stringView->ResizeToPreferred(); + AddChild(stringView); + + rect.OffsetBy(0, height + 10); + stringView = new BStringView(rect, "copyright2", "Based on OpenEXR (http://www.openexr.com)"); + stringView->ResizeToPreferred(); + AddChild(stringView); + + rect.OffsetBy(0, height + 5); + stringView = new BStringView(rect, "copyright3", B_UTF8_COPYRIGHT "2006, Industrial Light & Magic, a division of Lucasfilm " + "Entertainment Company Ltd"); + stringView->ResizeToPreferred(); + AddChild(stringView); +} + + +ConfigView::~ConfigView() +{ +} + Added: haiku/trunk/src/add-ons/translators/exr/ConfigView.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/ConfigView.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/ConfigView.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,19 @@ +/* + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef CONFIG_VIEW_H +#define CONFIG_VIEW_H + + +#include + + +class ConfigView : public BView { + public: + ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, + uint32 flags = B_WILL_DRAW); + virtual ~ConfigView(); +}; + +#endif /* CONFIG_VIEW_H */ Added: haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2004, Industrial Light & Magic, a division of Lucas + * Digital Ltd. LLC + * Distributed under the terms of the MIT License. + */ + +#include "EXRGamma.h" +#include "ImathFun.h" +#include "ImathMath.h" + +using namespace std; +using Imath::clamp; + + +float +knee(double x, double f) +{ + return float (Imath::Math::log (x * f + 1) / f); +} + + +float +findKneeF(float x, float y) +{ + float f0 = 0; + float f1 = 1; + + while (knee (x, f1) > y) + { + f0 = f1; + f1 = f1 * 2; + } + + for (int i = 0; i < 30; ++i) + { + float f2 = (f0 + f1) / 2; + float y2 = knee (x, f2); + + if (y2 < y) + f1 = f2; + else + f0 = f2; + } + + return (f0 + f1) / 2; +} + + +Gamma::Gamma(float gamma, + float exposure, + float defog, + float kneeLow, + float kneeHigh) +: + g (gamma), + m (Imath::Math::pow(2, exposure + 2.47393)), + d (defog), + kl (Imath::Math::pow(2, kneeLow)), + f (findKneeF (Imath::Math::pow(2, kneeHigh) - kl, + Imath::Math::pow(2, 3.5) - kl)), + s (255.0 * Imath::Math::pow(2, -3.5 * g)) +{ +} + + +float +Gamma::operator() (half h) +{ + // + // Defog + // + + float x = max (0.f, (h - d)); + + // + // Exposure + // + + x *= m; + + // + // Knee + // + + if (x > kl) + x = kl + knee (x - kl, f); + + // + // Gamma + // + + x = Imath::Math::pow (x, g); + + // + // Scale and clamp + // + + return clamp (x * s, 0.f, 255.f); +} Added: haiku/trunk/src/add-ons/translators/exr/EXRGamma.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/EXRGamma.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/EXRGamma.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2004, Industrial Light & Magic, a division of Lucas + * Digital Ltd. LLC + * Distributed under the terms of the MIT License. + */ +#ifndef EXR_GAMMA_H +#define EXR_GAMMA_H + +#include "halfFunction.h" + +struct Gamma +{ + float g, m, d, kl, f, s; + + Gamma(float gamma, + float exposure, + float defog, + float kneeLow, + float kneeHigh); + + float operator() (half h); +}; + +#endif Added: haiku/trunk/src/add-ons/translators/exr/EXRTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/EXRTranslator.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/EXRTranslator.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,246 @@ +/* + * Copyright 2008, J?r?me Duval. All rights reserved. + * Copyright (c) 2004, Industrial Light & Magic, a division of Lucas + * Digital Ltd. LLC + * Distributed under the terms of the MIT License. + */ + +#include "ConfigView.h" +#include "EXRGamma.h" +#include "EXRTranslator.h" +#include "ImfArray.h" +#undef min +#undef max +#include "ImfRgbaFile.h" +#include "IStreamWrapper.h" + + +// The input formats that this translator supports. +translation_format sInputFormats[] = { + { + EXR_IMAGE_FORMAT, + B_TRANSLATOR_BITMAP, + EXR_IN_QUALITY, + EXR_IN_CAPABILITY, + "image/exr", + "EXR" + }, +}; + +// The output formats that this translator supports. +translation_format sOutputFormats[] = { + { + B_TRANSLATOR_BITMAP, + B_TRANSLATOR_BITMAP, + BITS_OUT_QUALITY, + BITS_OUT_CAPABILITY, + "x-be-bitmap", + "Be Bitmap image" + }, +}; + +// Default settings for the Translator +static TranSetting sDefaultSettings[] = { + {B_TRANSLATOR_EXT_HEADER_ONLY, TRAN_SETTING_BOOL, false}, + {B_TRANSLATOR_EXT_DATA_ONLY, TRAN_SETTING_BOOL, false} +}; + +const uint32 kNumInputFormats = sizeof(sInputFormats) / sizeof(translation_format); +const uint32 kNumOutputFormats = sizeof(sOutputFormats) / sizeof(translation_format); +const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting); + + + + +// #pragma mark - + + +EXRTranslator::EXRTranslator() + : BaseTranslator("EXR Images", "EXR Image Translator", + EXR_TRANSLATOR_VERSION, + sInputFormats, kNumInputFormats, + sOutputFormats, kNumOutputFormats, + "EXRTranslator_Settings", + sDefaultSettings, kNumDefaultSettings, + B_TRANSLATOR_BITMAP, EXR_IMAGE_FORMAT) +{ +} + + +EXRTranslator::~EXRTranslator() +{ +} + + +status_t +EXRTranslator::DerivedIdentify(BPositionIO *stream, + const translation_format *format, BMessage *settings, + translator_info *outInfo, uint32 outType) +{ + if (!outType) + outType = B_TRANSLATOR_BITMAP; + if (outType != B_TRANSLATOR_BITMAP) + return B_NO_TRANSLATOR; + + try { + IStreamWrapper istream("filename", stream); + RgbaInputFile inputFile(istream); + + if (outInfo) { + outInfo->type = EXR_IMAGE_FORMAT; + outInfo->group = B_TRANSLATOR_BITMAP; + outInfo->quality = EXR_IN_QUALITY; + outInfo->capability = EXR_IN_CAPABILITY; + strcpy(outInfo->MIME, "image/exr"); + strcpy(outInfo->name, "EXR image"); + } + } catch (const std::exception &e) { + return B_NO_TRANSLATOR; + } + + return B_OK; +} + + +status_t +EXRTranslator::DerivedTranslate(BPositionIO* source, + const translator_info* info, BMessage* settings, + uint32 outType, BPositionIO* target, int32 baseType) +{ + if (!outType) + outType = B_TRANSLATOR_BITMAP; + if (outType != B_TRANSLATOR_BITMAP || baseType != 0) + return B_NO_TRANSLATOR; + + status_t err = B_NO_TRANSLATOR; + try { + IStreamWrapper istream("filename", source); + RgbaInputFile in(istream); + + //Imath::Box2i dw = in.dataWindow(); + const Imath::Box2i &displayWindow = in.displayWindow(); + const Imath::Box2i &dataWindow = in.dataWindow(); + float a = in.pixelAspectRatio(); // TODO take into account the aspect ratio + int dataWidth = dataWindow.max.x - dataWindow.min.x + 1; + int dataHeight = dataWindow.max.y - dataWindow.min.y + 1; + int displayWidth = displayWindow.max.x - displayWindow.min.x + 1; + int displayHeight = displayWindow.max.y - displayWindow.min.y + 1; + + // Write out the data to outDestination + // Construct and write Be bitmap header + TranslatorBitmap bitsHeader; + bitsHeader.magic = B_TRANSLATOR_BITMAP; + bitsHeader.bounds.left = 0; + bitsHeader.bounds.top = 0; + bitsHeader.bounds.right = displayWidth - 1; + bitsHeader.bounds.bottom = displayHeight - 1; + bitsHeader.rowBytes = 4 * displayWidth; + bitsHeader.colors = B_RGBA32; + bitsHeader.dataSize = bitsHeader.rowBytes * displayHeight; + if (swap_data(B_UINT32_TYPE, &bitsHeader, + sizeof(TranslatorBitmap), B_SWAP_HOST_TO_BENDIAN) != B_OK) { + return B_ERROR; + } + target->Write(&bitsHeader, sizeof(TranslatorBitmap)); + + Array2D pixels(dataHeight, dataWidth); + in.setFrameBuffer (&pixels[0][0] - dataWindow.min.y * dataWidth - dataWindow.min.x, 1, dataWidth); + in.readPixels (dataWindow.min.y, dataWindow.max.y); + + float _gamma = 0.4545f; + float _exposure = 0.0f; + float _defog = 0.0f; + float _kneeLow = 0.0f; + float _kneeHigh = 5.0f; + + float _fogR = 0.0f; + float _fogG = 0.0f; + float _fogB = 0.0f; + + halfFunction + rGamma (Gamma (_gamma, + _exposure, + _defog * _fogR, + _kneeLow, + _kneeHigh), + -HALF_MAX, HALF_MAX, + 0.f, 255.f, 0.f, 0.f); + + halfFunction + gGamma (Gamma (_gamma, + _exposure, + _defog * _fogG, + _kneeLow, + _kneeHigh), + -HALF_MAX, HALF_MAX, + 0.f, 255.f, 0.f, 0.f); + + halfFunction + bGamma (Gamma (_gamma, + _exposure, + _defog * _fogB, + _kneeLow, + _kneeHigh), + -HALF_MAX, HALF_MAX, + 0.f, 255.f, 0.f, 0.f); + + for (int y = displayWindow.min.y; y <= displayWindow.max.y; ++y) { + if (y < dataWindow.min.y + || y > dataWindow.max.y) { + unsigned char sp[4]; + sp[0] = 128; + sp[1] = 128; + sp[2] = 128; + sp[3] = 255; + for (int x = displayWindow.min.x; x <= displayWindow.max.x; ++x) { + target->Write(sp, 4); + } + continue; + } + + for (int x = displayWindow.min.x; x <= displayWindow.max.x; ++x) { + unsigned char sp[4]; + if (x < dataWindow.min.x + || x > dataWindow.max.x) { + sp[0] = 128; + sp[1] = 128; + sp[2] = 128; + sp[3] = 255; + } else { + const Imf::Rgba &rp = pixels[y][x]; + + sp[0] = (unsigned char)bGamma(rp.b); + sp[1] = (unsigned char)gGamma(rp.g); + sp[2] = (unsigned char)rGamma(rp.r); + sp[3] = 255; + } + target->Write(sp, 4); + } + } + + err = B_OK; + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + } + return err; +} + + +BView * +EXRTranslator::NewConfigView(TranslatorSettings *settings) +{ + return new ConfigView(BRect(0, 0, 225, 175)); +} + + +// #pragma mark - + + +BTranslator * +make_nth_translator(int32 n, image_id you, uint32 flags, ...) +{ + if (n != 0) + return NULL; + + return new EXRTranslator(); +} Added: haiku/trunk/src/add-ons/translators/exr/EXRTranslator.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/EXRTranslator.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/EXRTranslator.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,45 @@ +/* + * Copyright 2008, J?r?me Duval. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef EXR_TRANSLATOR_H +#define EXR_TRANSLATOR_H + + +#include "BaseTranslator.h" + + +#define EXR_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(0, 1, 0) +#define EXR_IMAGE_FORMAT 'EXRI' + +#define EXR_IN_QUALITY 0.90 +#define EXR_IN_CAPABILITY 0.90 +#define BITS_IN_QUALITY 1 +#define BITS_IN_CAPABILITY 1 + +#define EXR_OUT_QUALITY 0.8 +#define EXR_OUT_CAPABILITY 0.8 +#define BITS_OUT_QUALITY 1 +#define BITS_OUT_CAPABILITY 0.9 + + +class EXRTranslator : public BaseTranslator { + public: + EXRTranslator(); + virtual ~EXRTranslator(); + + virtual status_t DerivedIdentify(BPositionIO *inSource, + const translation_format *inFormat, BMessage *ioExtension, + translator_info *outInfo, uint32 outType); + + virtual status_t DerivedTranslate(BPositionIO *inSource, + const translator_info *inInfo, BMessage *ioExtension, + uint32 outType, BPositionIO *outDestination, int32 baseType); + + virtual BView *NewConfigView(TranslatorSettings *settings); + + private: +}; + +#endif // EXR_TRANSLATOR_H + Added: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,43 @@ +/* + * Copyright 2008, J?r?me Duval. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "IStreamWrapper.h" + +IStreamWrapper::IStreamWrapper(const char *filename, BPositionIO *stream) + : IStream(filename), + fStream(stream) +{ +} + + +IStreamWrapper::~IStreamWrapper() +{ +} + + +bool +IStreamWrapper::read(char c[/*n*/], int n) +{ + int actual = fStream->Read(c, n); + if (actual < B_OK) { + + } + return (actual == n); +} + + +Int64 +IStreamWrapper::tellg() +{ + return fStream->Position(); +} + + +void +IStreamWrapper::seekg(Int64 pos) +{ + fStream->Seek(pos, SEEK_SET); +} Added: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,27 @@ +/* + * Copyright 2008, J?r?me Duval. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef ISTREAM_WRAPPER_H +#define ISTREAM_WRAPPER_H + +#include +#include + +using namespace Imf; + +class IStreamWrapper : public IStream { + public: + IStreamWrapper(const char *filename, BPositionIO *stream); + virtual ~IStreamWrapper(); + + virtual bool read(char c[/*n*/], int n); + virtual Int64 tellg(); + virtual void seekg(Int64 pos); + + private: + BPositionIO *fStream; +}; + +#endif /* ISTREAM_WRAPPER_H */ + Added: haiku/trunk/src/add-ons/translators/exr/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,32 @@ +SubDir HAIKU_TOP src add-ons translators exr ; + +SubDirSysHdrs [ FDirName $(SUBDIR) openexr half ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) openexr iex ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) openexr ilmimf ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) openexr imath ] ; + +# Include code from shared translator directory +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; + +Translator EXRTranslator : + main.cpp + ConfigView.cpp + EXRGamma.cpp + EXRTranslator.cpp + IStreamWrapper.cpp + + # shared classes + BaseTranslator.cpp + TranslatorSettings.cpp + TranslatorWindow.cpp + + : be translation libilmimf.so + : true +; + +Package haiku-translationkit-cvs : + EXRTranslator : + boot home config add-ons Translators ; + +SubInclude HAIKU_TOP src add-ons translators exr openexr ; + Added: haiku/trunk/src/add-ons/translators/exr/main.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/main.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/main.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,26 @@ +/* + * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "EXRTranslator.h" + +#include "TranslatorWindow.h" +#include + + +int +main(int /*argc*/, char **/*argv*/) +{ + BApplication app("application/x-vnd.haiku-exr-translator"); + + status_t result; + result = LaunchTranslatorWindow(new EXRTranslator, "EXR Settings", BRect(0, 0, 225, 175)); + if (result != B_OK) + return 1; + + app.Run(); + return 0; +} + Added: haiku/trunk/src/add-ons/translators/exr/openexr/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/Jamfile 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/openexr/Jamfile 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,20 @@ +SubDir HAIKU_TOP src add-ons translators exr openexr ; + +SubDirSysHdrs [ FDirName $(SUBDIR) half ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) iex ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) ilmimf ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) ilmthread ] ; +SubDirSysHdrs [ FDirName $(SUBDIR) imath ] ; +SubDirHdrs [ FDirName $(SUBDIR) config ] ; + +BinCommand exrheader : + exrheader.cpp + : libilmimf.so $(TARGET_LIBSTDC++) +; + +SubInclude HAIKU_TOP src add-ons translators exr openexr half ; +SubInclude HAIKU_TOP src add-ons translators exr openexr iex ; +SubInclude HAIKU_TOP src add-ons translators exr openexr ilmimf ; +SubInclude HAIKU_TOP src add-ons translators exr openexr ilmthread ; +SubInclude HAIKU_TOP src add-ons translators exr openexr imath ; + Added: haiku/trunk/src/add-ons/translators/exr/openexr/config/IlmBaseConfig.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/config/IlmBaseConfig.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/openexr/config/IlmBaseConfig.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,16 @@ +/* config/IlmBaseConfig.h. Generated by configure. */ +// +// Define and set to 1 if the target system has POSIX thread support +// and you want IlmBase to use it for multithreaded file I/O. +// + +/* #undef HAVE_PTHREAD */ + +// +// Define and set to 1 if the target system supports POSIX semaphores +// and you want OpenEXR to use them; otherwise, OpenEXR will use its +// own semaphore implementation. +// + +/* #undef HAVE_POSIX_SEMAPHORES */ + Added: haiku/trunk/src/add-ons/translators/exr/openexr/config/OpenEXRConfig.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/config/OpenEXRConfig.h 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/openexr/config/OpenEXRConfig.h 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,32 @@ +/* config/OpenEXRConfig.h. Generated by configure. */ +// +// Define and set to 1 if the target system supports a proc filesystem +// compatible with the Linux kernel's proc filesystem. Note that this +// is only used by a program in the IlmImfTest test suite, it's not +// used by any OpenEXR library or application code. +// + +#define HAVE_LINUX_PROCFS 1 + +// +// Define and set to 1 if the target system is a Darwin-based system +// (e.g., OS X). +// + +/* #undef HAVE_DARWIN */ + +// +// Define and set to 1 if the target system has a complete +// implementation, specifically if it supports the std::right +// formatter. +// + +#define HAVE_COMPLETE_IOMANIP 1 + +// +// Define and set to 1 if the target system has support for large +// stack sizes. +// + +#define HAVE_LARGE_STACK 1 + Added: haiku/trunk/src/add-ons/translators/exr/openexr/exrheader.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/exrheader.cpp 2008-02-03 11:39:28 UTC (rev 23833) +++ haiku/trunk/src/add-ons/translators/exr/openexr/exrheader.cpp 2008-02-03 13:01:23 UTC (rev 23834) @@ -0,0 +1,501 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas +// Digital Ltd. LLC +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Industrial Light & Magic nor the names of +// its contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////// + + +//----------------------------------------------------------------------------- +// +// Utility program to print an image file's header +// +//----------------------------------------------------------------------------- + +#include "OpenEXRConfig.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Imf; +using namespace std; + + +void +printCompression (Compression c) +{ + switch (c) + { + case NO_COMPRESSION: + cout << "none"; + break; + + case RLE_COMPRESSION: + cout << "run-length encoding"; + break; + + case ZIPS_COMPRESSION: + cout << "zip, individual scanlines"; + break; + + case ZIP_COMPRESSION: + cout << "zip, multi-scanline blocks"; + break; + + case PIZ_COMPRESSION: + cout << "piz"; + break; + + case PXR24_COMPRESSION: + cout << "pxr24"; + break; + + case B44_COMPRESSION: + cout << "b44"; + break; + + case B44A_COMPRESSION: + cout << "b44a"; + break; + + default: + cout << int (c); + break; + } +} + + +void +printLineOrder (LineOrder lo) +{ + switch (lo) + { + case INCREASING_Y: + cout << "increasing y"; + break; + + case DECREASING_Y: + cout << "decreasing y"; + break; + + case RANDOM_Y: + cout << "random y"; + break; + + default: + cout << int (lo); + break; + }; +} + + +void +printPixelType (PixelType pt) +{ + switch (pt) + { + case UINT: + cout << "32-bit unsigned integer"; + break; + + case HALF: + cout << "16-bit floating-point"; + break; + + case FLOAT: + cout << "32-bit floating-point"; + break; + + default: + cout << "type " << int (pt); + break; + } +} + + +void +printLevelMode (LevelMode lm) +{ + switch (lm) + { + case ONE_LEVEL: + cout << "single level"; + break; + + case MIPMAP_LEVELS: + cout << "mip-map"; + break; + + case RIPMAP_LEVELS: + cout << "rip-map"; + break; + + default: + cout << "level mode " << int (lm); + break; + } +} + + +void +printLevelRoundingMode (LevelRoundingMode lm) +{ + switch (lm) + { + case ROUND_DOWN: + cout << "down"; + break; + + case ROUND_UP: + cout << "up"; + break; + + default: + cout << "mode " << int (lm); + break; + } +} + + +void +printTimeCode (TimeCode tc) +{ [... truncated: 88856 lines follow ...] From axeld at mail.berlios.de Sun Feb 3 16:31:17 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 16:31:17 +0100 Subject: [Haiku-commits] r23835 - in haiku/trunk: headers/posix src/system/libroot/posix Message-ID: <200802031531.m13FVHdd000507@sheep.berlios.de> Author: axeld Date: 2008-02-03 16:31:16 +0100 (Sun, 03 Feb 2008) New Revision: 23835 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23835&view=rev Modified: haiku/trunk/headers/posix/syslog.h haiku/trunk/src/system/libroot/posix/syslog.cpp Log: Added BSD extension vsyslog() - is also found on Linux. Modified: haiku/trunk/headers/posix/syslog.h =================================================================== --- haiku/trunk/headers/posix/syslog.h 2008-02-03 13:01:23 UTC (rev 23834) +++ haiku/trunk/headers/posix/syslog.h 2008-02-03 15:31:16 UTC (rev 23835) @@ -6,6 +6,9 @@ #define _SYSLOG_H_ +#include + + /* options for openlog() */ #define LOG_PID (1 << 12) /* log the process (thread/team) ID with each message */ @@ -80,6 +83,9 @@ extern void log_thread(int priority, const char *message, ...); extern int setlogmask_thread(int priorityMask); +/* BSD extensions */ +extern void vsyslog(int priority, const char *message, va_list args); + #ifdef __cplusplus } #endif Modified: haiku/trunk/src/system/libroot/posix/syslog.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/syslog.cpp 2008-02-03 13:01:23 UTC (rev 23834) +++ haiku/trunk/src/system/libroot/posix/syslog.cpp 2008-02-03 15:31:16 UTC (rev 23835) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -162,18 +162,53 @@ } -// #pragma mark - public Be API +// #pragma mark - POSIX API + + +void +closelog(void) +{ + closelog_thread(); +} + + +void +openlog(const char *ident, int options, int facility) +{ + openlog_thread(ident, options, facility); +} + + +int +setlogmask(int priorityMask) +{ + return setlogmask_thread(priorityMask); +} + + +void +syslog(int priority, const char *message, ...) +{ + va_list args; + + va_start(args, message); + send_syslog_message(get_context(), priority, message, args); + va_end(args); +} + + +// #pragma mark - Be extensions // ToDo: it would probably be better to export these symbols as weak symbols only -void +void closelog_team(void) { // nothing to do here... } -void +void openlog_team(const char *ident, int options, int facility) { if (ident != NULL) @@ -184,7 +219,7 @@ } -int +int setlogmask_team(int priorityMask) { int oldMask = sTeamContext.mask; @@ -196,18 +231,18 @@ } -void +void log_team(int priority, const char *message, ...) { va_list args; - + va_start(args, message); send_syslog_message(&sTeamContext, priority, message, args); va_end(args); } -void +void closelog_thread(void) { if (sThreadContextSlot < 0) @@ -218,7 +253,7 @@ } -void +void openlog_thread(const char *ident, int options, int facility) { syslog_context *context = get_context(); @@ -231,7 +266,7 @@ } -int +int setlogmask_thread(int priorityMask) { syslog_context *context = get_context(); @@ -244,49 +279,23 @@ } -void +void log_thread(int priority, const char *message, ...) { va_list args; - + va_start(args, message); send_syslog_message(get_context(), priority, message, args); va_end(args); } -// #pragma mark - POSIX API +// #pragma mark - BSD extensions -void -closelog(void) +void +vsyslog(int priority, const char *message, va_list args) { - closelog_thread(); -} - - -void -openlog(const char *ident, int options, int facility) -{ - openlog_thread(ident, options, facility); -} - - -int -setlogmask(int priorityMask) -{ - return setlogmask_thread(priorityMask); -} - - -void -syslog(int priority, const char *message, ...) -{ - va_list args; - - va_start(args, message); send_syslog_message(get_context(), priority, message, args); - va_end(args); } - From axeld at mail.berlios.de Sun Feb 3 16:37:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 16:37:32 +0100 Subject: [Haiku-commits] r23836 - in haiku/trunk: headers/posix headers/posix/sys headers/private/kernel src/system/kernel/fs src/system/libroot/posix/sys Message-ID: <200802031537.m13FbWoe000783@sheep.berlios.de> Author: axeld Date: 2008-02-03 16:37:31 +0100 (Sun, 03 Feb 2008) New Revision: 23836 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23836&view=rev Added: haiku/trunk/headers/posix/sys/file.h haiku/trunk/src/system/libroot/posix/sys/flock.c Modified: haiku/trunk/headers/posix/fcntl.h haiku/trunk/headers/posix/sys/stat.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/libroot/posix/sys/Jamfile Log: * Implemented flock() semantics to the advisory locking backend. Not tested (must also compare to BSD; I've looked at their sources, but I might have missed something). * Added sys/file.h and the flock() system call. * common_fcntl() could forget to put back the file descriptor on some error conditions (I guess we should introduce and use a DescriptorGetter class). * Cleaned up fcntl.h, moved the BSD extensions S_IREAD and S_IWRITE to sys/stat.h where they belong, and added the missing S_IEXEC to them. * Added some more comments. Modified: haiku/trunk/headers/posix/fcntl.h =================================================================== --- haiku/trunk/headers/posix/fcntl.h 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/headers/posix/fcntl.h 2008-02-03 15:37:31 UTC (rev 23836) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku Inc. All Rights Reserved. + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FCNTL_H @@ -74,16 +74,7 @@ pid_t l_pid; }; -/* for use with flock() - TODO: this should be moved to sys/file.h *if* we'll support flock() one day */ -#define LOCK_SH 0x01 /* shared file lock */ -#define LOCK_EX 0x02 /* exclusive file lock */ -#define LOCK_NB 0x04 /* don't block when locking */ -#define LOCK_UN 0x08 /* unlock file */ -#define S_IREAD 0x0100 /* owner may read */ -#define S_IWRITE 0x0080 /* owner may write */ - - #ifdef __cplusplus extern "C" { #endif @@ -99,4 +90,4 @@ } #endif -#endif /* _FCNTL_H */ +#endif /* _FCNTL_H */ Added: haiku/trunk/headers/posix/sys/file.h =================================================================== --- haiku/trunk/headers/posix/sys/file.h 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/headers/posix/sys/file.h 2008-02-03 15:37:31 UTC (rev 23836) @@ -0,0 +1,29 @@ +/* + * Copyright 2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYS_FILE_H +#define _SYS_FILE_H + + +#include + + +/* for use with flock() */ +#define LOCK_SH 0x01 /* shared file lock */ +#define LOCK_EX 0x02 /* exclusive file lock */ +#define LOCK_NB 0x04 /* don't block when locking */ +#define LOCK_UN 0x08 /* unlock file */ + + +#ifdef __cplusplus +extern "C" { +#endif + +extern int flock(int fd, int op); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FILE_H */ Modified: haiku/trunk/headers/posix/sys/stat.h =================================================================== --- haiku/trunk/headers/posix/sys/stat.h 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/headers/posix/sys/stat.h 2008-02-03 15:37:31 UTC (rev 23836) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Haiku Inc. All Rights Reserved. + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_STAT_H_ @@ -85,6 +85,11 @@ #define S_IWOTH 00002 /* write permission: other */ #define S_IXOTH 00001 /* execute permission: other */ +/* BSD extensions */ +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR + #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) #define ALLPERMS (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO) #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-02-03 15:37:31 UTC (rev 23836) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Haiku Inc. All rights reserved. + * Copyright 2004-2008, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_SYSCALLS_H @@ -151,6 +151,7 @@ size_t nameLength); extern status_t _kern_fcntl(int fd, int op, uint32 argument); extern status_t _kern_fsync(int fd); +extern status_t _kern_flock(int fd, int op); extern off_t _kern_seek(int fd, off_t pos, int seekType); extern status_t _kern_create_dir_entry_ref(dev_t device, ino_t inode, const char *name, int perms); extern status_t _kern_create_dir(int fd, const char *path, int perms); Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/headers/private/kernel/vfs.h 2008-02-03 15:37:31 UTC (rev 23836) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -145,6 +145,7 @@ int _user_open_parent_dir(int fd, char *name, size_t nameLength); status_t _user_fcntl(int fd, int op, uint32 argument); status_t _user_fsync(int fd); +status_t _user_flock(int fd, int op); status_t _user_read_stat(int fd, const char *path, bool traverseLink, struct stat *stat, size_t statSize); status_t _user_write_stat(int fd, const char *path, bool traverseLink, Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-03 15:37:31 UTC (rev 23836) @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -128,6 +129,7 @@ struct advisory_lock { list_link link; team_id team; + pid_t session; off_t offset; off_t length; bool shared; @@ -1088,7 +1090,6 @@ /*! Retrieves the first lock that has been set by the current team. */ - static status_t get_advisory_lock(struct vnode *vnode, struct flock *flock) { @@ -1128,15 +1129,18 @@ return flock != NULL ? B_BAD_VALUE : B_OK; team_id team = team_get_current_team_id(); + pid_t session = thread_get_current_thread()->team->session_id; // find matching lock entry status_t status = B_BAD_VALUE; struct advisory_lock *lock = NULL; - while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, lock)) != NULL) { - if (lock->team == team && (flock == NULL || (flock != NULL - && lock->offset == flock->l_start - && lock->length == flock->l_len))) { + while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, + lock)) != NULL) { + if (lock->team == team && (flock == NULL + || (flock != NULL && lock->offset == flock->l_start + && lock->length == flock->l_len)) + || lock->session == session) { // we found our lock, free it list_remove_item(&locking->locks, lock); free(lock); @@ -1176,8 +1180,18 @@ } +/*! Acquires an advisory lock for the \a vnode. If \a wait is \c true, it + will wait for the lock to become available, if there are any collisions + (it will return B_PERMISSION_DENIED in this case if \a wait is \c false). + + If \a session is -1, POSIX semantics are used for this lock. Otherwise, + BSD flock() semantics are used, that is, all children can unlock the file + in question (we even allow parents to remove the lock, though, but that + seems to be in line to what the BSD's are doing). +*/ static status_t -acquire_advisory_lock(struct vnode *vnode, struct flock *flock, bool wait) +acquire_advisory_lock(struct vnode *vnode, pid_t session, struct flock *flock, + bool wait) { FUNCTION(("acquire_advisory_lock(vnode = %p, flock = %p, wait = %s)\n", vnode, flock, wait ? "yes" : "no")); @@ -1185,6 +1199,8 @@ bool shared = flock->l_type == F_RDLCK; status_t status = B_OK; + // TODO: do deadlock detection! + restart: // if this vnode has an advisory_locking structure attached, // lock that one and search for any colliding file lock @@ -1194,7 +1210,8 @@ if (locking != NULL) { // test for collisions struct advisory_lock *lock = NULL; - while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, lock)) != NULL) { + while ((lock = (struct advisory_lock *)list_get_next_item( + &locking->locks, lock)) != NULL) { if (lock->offset <= flock->l_start + flock->l_len && lock->offset + lock->length > flock->l_start) { // locks do overlap @@ -1214,9 +1231,10 @@ if (waitForLock >= B_OK) { if (!wait) - status = B_PERMISSION_DENIED; + status = session != -1 ? B_WOULD_BLOCK : B_PERMISSION_DENIED; else { - status = switch_sem_etc(locking->lock, waitForLock, 1, B_CAN_INTERRUPT, 0); + status = switch_sem_etc(locking->lock, waitForLock, 1, + B_CAN_INTERRUPT, 0); if (status == B_OK) { // see if we're still colliding goto restart; @@ -1240,7 +1258,8 @@ // we own the locking object, so it can't go away } - struct advisory_lock *lock = (struct advisory_lock *)malloc(sizeof(struct advisory_lock)); + struct advisory_lock *lock = (struct advisory_lock *)malloc( + sizeof(struct advisory_lock)); if (lock == NULL) { if (waitForLock >= B_OK) release_sem_etc(waitForLock, 1, B_RELEASE_ALL); @@ -1249,6 +1268,7 @@ } lock->team = team_get_current_team_id(); + lock->session = session; // values must already be normalized when getting here lock->offset = flock->l_start; lock->length = flock->l_len; @@ -1261,6 +1281,10 @@ } +/*! Normalizes the \a flock structure to make it easier to compare the + structure with others. The l_start and l_len fields are set to absolute + values according to the l_whence field. +*/ static status_t normalize_flock(struct file_descriptor *descriptor, struct flock *flock) { @@ -1279,7 +1303,8 @@ if (FS_CALL(vnode, read_stat) == NULL) return EOPNOTSUPP; - status = FS_CALL(vnode, read_stat)(vnode->mount->cookie, vnode->private_node, &stat); + status = FS_CALL(vnode, read_stat)(vnode->mount->cookie, + vnode->private_node, &stat); if (status < B_OK) return status; @@ -4512,7 +4537,6 @@ struct file_descriptor *descriptor; struct vnode *vnode; struct flock flock; - status_t status; FUNCTION(("common_fcntl(fd = %d, op = %d, argument = %lx, %s)\n", fd, op, argument, kernel ? "kernel" : "user")); @@ -4521,11 +4545,19 @@ if (descriptor == NULL) return B_FILE_ERROR; + status_t status = B_OK; + if (op == F_SETLK || op == F_SETLKW || op == F_GETLK) { if (descriptor->type != FDTYPE_FILE) - return B_BAD_VALUE; - if (user_memcpy(&flock, (struct flock *)argument, sizeof(struct flock)) < B_OK) - return B_BAD_ADDRESS; + status = B_BAD_VALUE; + else if (user_memcpy(&flock, (struct flock *)argument, + sizeof(struct flock)) < B_OK) + status = B_BAD_ADDRESS; + + if (status != B_OK) { + put_fd(descriptor); + return status; + } } switch (op) { @@ -4564,8 +4596,8 @@ vnode->private_node, descriptor->cookie, (int)argument); if (status == B_OK) { // update this descriptor's open_mode field - descriptor->open_mode = (descriptor->open_mode & ~(O_APPEND | O_NONBLOCK)) - | argument; + descriptor->open_mode = (descriptor->open_mode + & ~(O_APPEND | O_NONBLOCK)) | argument; } } else status = EOPNOTSUPP; @@ -4595,7 +4627,8 @@ status = get_advisory_lock(descriptor->u.vnode, &flock); if (status == B_OK) { // copy back flock structure - status = user_memcpy((struct flock *)argument, &flock, sizeof(struct flock)); + status = user_memcpy((struct flock *)argument, &flock, + sizeof(struct flock)); } break; @@ -4609,11 +4642,15 @@ status = release_advisory_lock(descriptor->u.vnode, &flock); else { // the open mode must match the lock type - if ((descriptor->open_mode & O_RWMASK) == O_RDONLY && flock.l_type == F_WRLCK - || (descriptor->open_mode & O_RWMASK) == O_WRONLY && flock.l_type == F_RDLCK) + if ((descriptor->open_mode & O_RWMASK) == O_RDONLY + && flock.l_type == F_WRLCK + || (descriptor->open_mode & O_RWMASK) == O_WRONLY + && flock.l_type == F_RDLCK) status = B_FILE_ERROR; - else - status = acquire_advisory_lock(descriptor->u.vnode, &flock, op == F_SETLKW); + else { + status = acquire_advisory_lock(descriptor->u.vnode, -1, + &flock, op == F_SETLKW); + } } break; @@ -7287,6 +7324,43 @@ } +status_t +_user_flock(int fd, int op) +{ + struct file_descriptor *descriptor; + struct vnode *vnode; + struct flock flock; + status_t status; + + FUNCTION(("_user_fcntl(fd = %d, op = %d)\n", fd, op)); + + descriptor = get_fd_and_vnode(fd, &vnode, false); + if (descriptor == NULL) + return B_FILE_ERROR; + + if (descriptor->type != FDTYPE_FILE) { + put_fd(descriptor); + return B_BAD_VALUE; + } + + flock.l_start = 0; + flock.l_len = OFF_MAX; + flock.l_whence = 0; + flock.l_type = (op & LOCK_SH) != 0 ? F_RDLCK : F_WRLCK; + + if ((op & LOCK_UN) != 0) + status = release_advisory_lock(descriptor->u.vnode, &flock); + else { + status = acquire_advisory_lock(descriptor->u.vnode, + thread_get_current_thread()->team->session_id, &flock, + (op & LOCK_NB) == 0); + } + + put_fd(descriptor); + return status; +} + + status_t _user_lock_node(int fd) { Modified: haiku/trunk/src/system/libroot/posix/sys/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/Jamfile 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/src/system/libroot/posix/sys/Jamfile 2008-02-03 15:37:31 UTC (rev 23836) @@ -4,6 +4,7 @@ MergeObject posix_sys.o : chmod.c + flock.c ftime.c getrusage.c gettimeofday.c Added: haiku/trunk/src/system/libroot/posix/sys/flock.c =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/flock.c 2008-02-03 15:31:16 UTC (rev 23835) +++ haiku/trunk/src/system/libroot/posix/sys/flock.c 2008-02-03 15:37:31 UTC (rev 23836) @@ -0,0 +1,24 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + + +int +flock(int fd, int op) +{ + status_t status = _kern_flock(fd, op); + if (status < B_OK) { + errno = status; + return -1; + } + + return 0; +} + From jackburton at mail.berlios.de Sun Feb 3 17:02:13 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 3 Feb 2008 17:02:13 +0100 Subject: [Haiku-commits] r23837 - haiku/trunk/src/kits/interface Message-ID: <200802031602.m13G2DKE002873@sheep.berlios.de> Author: jackburton Date: 2008-02-03 17:02:13 +0100 (Sun, 03 Feb 2008) New Revision: 23837 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23837&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: Previous revision break all sorts of stuff. Fixed. hopefully Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2008-02-03 15:37:31 UTC (rev 23836) +++ haiku/trunk/src/kits/interface/TextView.cpp 2008-02-03 16:02:13 UTC (rev 23837) @@ -3056,7 +3056,7 @@ } else _DoInsertText(bytes, numBytes, fSelStart, NULL, NULL); - fSelStart = fSelEnd = fClickOffset = fSelStart + numBytes; + fClickOffset = fSelEnd; ScrollToOffset(fClickOffset); } @@ -3481,12 +3481,9 @@ if (TextLength() + inLength > MaxBytes()) return; - if (fSelStart != fSelEnd - && fSelStart != 0 - && fSelEnd != 0) { - + if (fSelStart != fSelEnd) Select(fSelStart, fSelStart); - } + // Don't do any check, the public methods will have adjusted // eventual bogus values... @@ -3496,6 +3493,11 @@ // copy data into buffer InsertText(inText, inLength, inOffset, inRuns); + + // offset the caret/selection + //int32 saveStart = fSelStart; + fSelStart += inLength; + fSelEnd += inLength; // recalc line breaks and draw the text _Refresh(inOffset, textLength, true, false); From mmlr at mail.berlios.de Sun Feb 3 17:16:18 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 3 Feb 2008 17:16:18 +0100 Subject: [Haiku-commits] r23838 - in haiku/trunk: headers/os/drivers src/system/kernel src/system/kernel/arch/x86 src/system/kernel/debug Message-ID: <200802031616.m13GGIpR005054@sheep.berlios.de> Author: mmlr Date: 2008-02-03 17:16:17 +0100 (Sun, 03 Feb 2008) New Revision: 23838 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23838&view=rev Modified: haiku/trunk/headers/os/drivers/KernelExport.h haiku/trunk/src/system/kernel/arch/x86/arch_smp.c haiku/trunk/src/system/kernel/debug/debug.cpp haiku/trunk/src/system/kernel/int.c haiku/trunk/src/system/kernel/smp.c Log: Introduce a B_NO_LOCK_VECTOR flag to be used with install_io_interrupt_handler(). When specified it desigantes that the interrupt handler should not lock the vector with a spinlock when executing the installed interrupt handlers. This is necessary to allow the same interrupt vector to be handled in parallel on different CPUs. And it is required for the CPU halt to work synchronously when there is more than one AP CPU. Though the acquire_spinlock() should cause IPIs to be processed, only this fixed the SMP_MSG_FLAG_SYNC problem for me. Not locking is safe as long as it is guaranteed that no interrupt handler is registered or removed while the interrupt handler is running. We can guarantee this for the SMP interrupt handlers we install in arch_smp_init() as they are never uninstalled. Probably this flag should be made private though. Restored the SMP_MSG_FLAG_SYNC when entering the kernel debugger. Modified: haiku/trunk/headers/os/drivers/KernelExport.h =================================================================== --- haiku/trunk/headers/os/drivers/KernelExport.h 2008-02-03 16:02:13 UTC (rev 23837) +++ haiku/trunk/headers/os/drivers/KernelExport.h 2008-02-03 16:16:17 UTC (rev 23838) @@ -47,6 +47,7 @@ /* Flags that can be passed to install_io_interrupt_handler() */ #define B_NO_ENABLE_COUNTER 1 +#define B_NO_LOCK_VECTOR 2 extern status_t install_io_interrupt_handler(long interrupt_number, interrupt_handler handler, void *data, ulong flags); Modified: haiku/trunk/src/system/kernel/arch/x86/arch_smp.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_smp.c 2008-02-03 16:02:13 UTC (rev 23837) +++ haiku/trunk/src/system/kernel/arch/x86/arch_smp.c 2008-02-03 16:16:17 UTC (rev 23838) @@ -197,10 +197,10 @@ arch_smp_per_cpu_init(args, 0); // I/O interrupts start at ARCH_INTERRUPT_BASE, so all interrupts are shifted - install_io_interrupt_handler(0xfb - ARCH_INTERRUPT_BASE, &i386_timer_interrupt, NULL, 0); - install_io_interrupt_handler(0xfd - ARCH_INTERRUPT_BASE, &i386_ici_interrupt, NULL, 0); - install_io_interrupt_handler(0xfe - ARCH_INTERRUPT_BASE, &i386_smp_error_interrupt, NULL, 0); - install_io_interrupt_handler(0xff - ARCH_INTERRUPT_BASE, &i386_spurious_interrupt, NULL, 0); + install_io_interrupt_handler(0xfb - ARCH_INTERRUPT_BASE, &i386_timer_interrupt, NULL, B_NO_LOCK_VECTOR); + install_io_interrupt_handler(0xfd - ARCH_INTERRUPT_BASE, &i386_ici_interrupt, NULL, B_NO_LOCK_VECTOR); + install_io_interrupt_handler(0xfe - ARCH_INTERRUPT_BASE, &i386_smp_error_interrupt, NULL, B_NO_LOCK_VECTOR); + install_io_interrupt_handler(0xff - ARCH_INTERRUPT_BASE, &i386_spurious_interrupt, NULL, B_NO_LOCK_VECTOR); } return B_OK; } Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-03 16:02:13 UTC (rev 23837) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-03 16:16:17 UTC (rev 23838) @@ -1089,18 +1089,10 @@ if (sDebuggerOnCPU != smp_get_current_cpu() && smp_get_num_cpus() > 1) { // First entry on a MP system, send a halt request to all of the other - // CPUs but don't block here if they currently can't process it. - // Should they try to enter the debugger they will be cought in the - // loop above. - // ToDo: investigate why we sometimes hang here with SMP_MSG_FLAG_SYNC - // and readd that flag and remove the spin below when it's fixed. + // CPUs. Should they try to enter the debugger they will be cought in + // the loop above. smp_send_broadcast_ici(SMP_MSG_CPU_HALT, 0, 0, 0, - (void *)&inDebugger, 0); - - // Delay a bit to give other CPUs the chance to process the halt - // request. Otherwise we could get debug output of other CPUs mixed - // into our own when enabling debug output below. - spin(50000); + (void *)&inDebugger, SMP_MSG_FLAG_SYNC); } if (sBlueScreenOutput) { Modified: haiku/trunk/src/system/kernel/int.c =================================================================== --- haiku/trunk/src/system/kernel/int.c 2008-02-03 16:02:13 UTC (rev 23837) +++ haiku/trunk/src/system/kernel/int.c 2008-02-03 16:16:17 UTC (rev 23838) @@ -40,6 +40,7 @@ struct io_handler handler_list; spinlock vector_lock; int32 enable_count; + bool no_lock_vector; #ifdef DEBUG_INT int64 handled_count; int64 unhandled_count; @@ -124,6 +125,7 @@ for (i = 0; i < NUM_IO_VECTORS; i++) { io_vectors[i].vector_lock = 0; /* initialize spinlock */ io_vectors[i].enable_count = 0; + io_vectors[i].no_lock_vector = false; #ifdef DEBUG_INT io_vectors[i].handled_count = 0; io_vectors[i].unhandled_count = 0; @@ -189,6 +191,16 @@ arch_int_enable_io_interrupt(vector); } + // If B_NO_LOCK_VECTOR is specified this is a vector that is not supposed + // to have multiple handlers and does not require locking of the vector + // when entering the handler. For example this is used by internally + // registered interrupt handlers like for handling local APIC interrupts + // that may run concurently on multiple CPUs. Locking with a spinlock + // would in that case defeat the purpose as it would serialize calling the + // handlers in parallel on different CPUs. + if (flags & B_NO_LOCK_VECTOR) + io_vectors[vector].no_lock_vector = true; + release_spinlock(&io_vectors[vector].vector_lock); restore_interrupts(state); @@ -254,12 +266,14 @@ struct io_handler *io; bool invokeScheduler = false, handled = false; - acquire_spinlock(&io_vectors[vector].vector_lock); + if (!io_vectors[vector].no_lock_vector) + acquire_spinlock(&io_vectors[vector].vector_lock); // The list can be empty at this place if (io_vectors[vector].handler_list.next == &io_vectors[vector].handler_list) { dprintf("unhandled io interrupt %d\n", vector); - release_spinlock(&io_vectors[vector].vector_lock); + if (!io_vectors[vector].no_lock_vector) + release_spinlock(&io_vectors[vector].vector_lock); return B_UNHANDLED_INTERRUPT; } @@ -306,7 +320,8 @@ } #endif - release_spinlock(&io_vectors[vector].vector_lock); + if (!io_vectors[vector].no_lock_vector) + release_spinlock(&io_vectors[vector].vector_lock); if (levelTriggered) return status; Modified: haiku/trunk/src/system/kernel/smp.c =================================================================== --- haiku/trunk/src/system/kernel/smp.c 2008-02-03 16:02:13 UTC (rev 23837) +++ haiku/trunk/src/system/kernel/smp.c 2008-02-03 16:16:17 UTC (rev 23838) @@ -397,7 +397,7 @@ while (*haltValue != 0) PAUSE(); - + restore_interrupts(state); } From mmlr at mail.berlios.de Sun Feb 3 17:18:20 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 3 Feb 2008 17:18:20 +0100 Subject: [Haiku-commits] r23839 - haiku/trunk/src/system/kernel Message-ID: <200802031618.m13GIKox005153@sheep.berlios.de> Author: mmlr Date: 2008-02-03 17:18:19 +0100 (Sun, 03 Feb 2008) New Revision: 23839 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23839&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: Do not just overwrite the thread state when suspending a thread since this easily causes problems on SMP systems (triggers the panic in the scheduler). Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-02-03 16:16:17 UTC (rev 23838) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-02-03 16:18:19 UTC (rev 23839) @@ -902,7 +902,7 @@ if (thread->id != id) continue; - thread->state = thread->next_state = B_THREAD_SUSPENDED; + thread->next_state = B_THREAD_SUSPENDED; kprintf("thread %ld suspended\n", id); break; } From axeld at mail.berlios.de Sun Feb 3 17:20:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 17:20:16 +0100 Subject: [Haiku-commits] r23840 - in haiku/trunk: headers/compatibility/bsd src/libs/util Message-ID: <200802031620.m13GKGke005272@sheep.berlios.de> Author: axeld Date: 2008-02-03 17:20:16 +0100 (Sun, 03 Feb 2008) New Revision: 23840 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23840&view=rev Added: haiku/trunk/headers/compatibility/bsd/errno.h Modified: haiku/trunk/headers/compatibility/bsd/libutil.h haiku/trunk/headers/compatibility/bsd/signal.h haiku/trunk/src/libs/util/Jamfile haiku/trunk/src/libs/util/pidfile.c haiku/trunk/src/libs/util/realhostname.c Log: * Added BSD specific errno.h for EDOOFUS (yeah, I know, great error code...) * Added sigmask() macro. * Fixed libutil.h I broke yesterday: it's thought to add functions only if you've included some other headers before; added the correct header guard we're using for our sys/param.h. * Added pidfile.c to the build. * Fixed warning in realhostname.c, and pidfile.c. Added: haiku/trunk/headers/compatibility/bsd/errno.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/errno.h 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/headers/compatibility/bsd/errno.h 2008-02-03 16:20:16 UTC (rev 23840) @@ -0,0 +1,14 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _BSD_ERRNO_H_ +#define _BSD_ERRNO_H_ + + +#include_next + + +#define EDOOFUS EINVAL + +#endif /* _BSD_ERRNO_H_ */ Modified: haiku/trunk/headers/compatibility/bsd/libutil.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/headers/compatibility/bsd/libutil.h 2008-02-03 16:20:16 UTC (rev 23840) @@ -40,7 +40,6 @@ #define _LIBUTIL_H_ #include -#include #include #define PROPERTY_MAX_NAME 64 @@ -53,6 +52,7 @@ char *value; } *properties; +#ifdef _SYS_PARAM_H /* for pidfile.c */ struct pidfh { int pf_fd; @@ -60,6 +60,7 @@ dev_t pf_dev; ino_t pf_ino; }; +#endif /* Avoid pulling in all the include files for no need */ struct termios; @@ -119,10 +120,12 @@ int pw_tmp(int _mfd); #endif +#ifdef _SYS_PARAM_H struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr); int pidfile_write(struct pidfh *pfh); int pidfile_close(struct pidfh *pfh); int pidfile_remove(struct pidfh *pfh); +#endif __END_DECLS Modified: haiku/trunk/headers/compatibility/bsd/signal.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/signal.h 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/headers/compatibility/bsd/signal.h 2008-02-03 16:20:16 UTC (rev 23840) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _BSD_SIGNAL_H_ @@ -9,6 +9,9 @@ #include_next +#define sigmask(sig) (1 << ((sig) - 1)) + + #ifdef __cplusplus extern "C" { #endif Modified: haiku/trunk/src/libs/util/Jamfile =================================================================== --- haiku/trunk/src/libs/util/Jamfile 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/src/libs/util/Jamfile 2008-02-03 16:20:16 UTC (rev 23840) @@ -9,6 +9,7 @@ StaticLibrary libutil.a : fparseln.c + pidfile.c realhostname.c trimdomain.c ; Modified: haiku/trunk/src/libs/util/pidfile.c =================================================================== --- haiku/trunk/src/libs/util/pidfile.c 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/src/libs/util/pidfile.c 2008-02-03 16:20:16 UTC (rev 23840) @@ -172,7 +172,7 @@ return (-1); } - snprintf(pidstr, sizeof(pidstr), "%u", getpid()); + snprintf(pidstr, sizeof(pidstr), "%lu", getpid()); if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { error = errno; _pidfile_remove(pfh, 0); Modified: haiku/trunk/src/libs/util/realhostname.c =================================================================== --- haiku/trunk/src/libs/util/realhostname.c 2008-02-03 16:18:19 UTC (rev 23839) +++ haiku/trunk/src/libs/util/realhostname.c 2008-02-03 16:20:16 UTC (rev 23840) @@ -89,7 +89,9 @@ { int result, error; char buf[NI_MAXHOST]; +#ifdef INET6 struct sockaddr_in lsin; +#endif result = HOSTNAME_INVALIDADDR; From axeld at mail.berlios.de Sun Feb 3 17:34:33 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 17:34:33 +0100 Subject: [Haiku-commits] r23841 - in haiku/vendor/freebsd/current: . ftpd Message-ID: <200802031634.m13GYXhv006262@sheep.berlios.de> Author: axeld Date: 2008-02-03 17:34:29 +0100 (Sun, 03 Feb 2008) New Revision: 23841 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23841&view=rev Added: haiku/vendor/freebsd/current/ftpd/ haiku/vendor/freebsd/current/ftpd/Makefile haiku/vendor/freebsd/current/ftpd/config.h haiku/vendor/freebsd/current/ftpd/extern.h haiku/vendor/freebsd/current/ftpd/ftpchroot.5 haiku/vendor/freebsd/current/ftpd/ftpcmd.y haiku/vendor/freebsd/current/ftpd/ftpd.8 haiku/vendor/freebsd/current/ftpd/ftpd.c haiku/vendor/freebsd/current/ftpd/logwtmp.c haiku/vendor/freebsd/current/ftpd/md5.h haiku/vendor/freebsd/current/ftpd/md5c.c haiku/vendor/freebsd/current/ftpd/mdXhl.c haiku/vendor/freebsd/current/ftpd/pathnames.h haiku/vendor/freebsd/current/ftpd/popen.c Log: Added ftpd and parts of libmd into the FreeBSD vendor branch. Added: haiku/vendor/freebsd/current/ftpd/Makefile =================================================================== --- haiku/vendor/freebsd/current/ftpd/Makefile 2008-02-03 16:20:16 UTC (rev 23840) +++ haiku/vendor/freebsd/current/ftpd/Makefile 2008-02-03 16:34:29 UTC (rev 23841) @@ -0,0 +1,40 @@ +# @(#)Makefile 8.2 (Berkeley) 4/4/94 +# $FreeBSD: src/libexec/ftpd/Makefile,v 1.57 2006/06/05 15:50:34 yar Exp $ + +.include + +PROG= ftpd +MAN= ftpd.8 ftpchroot.5 +SRCS= ftpd.c ftpcmd.y logwtmp.c popen.c + +CFLAGS+=-DSETPROCTITLE -DLOGIN_CAP -DVIRTUAL_HOSTING +CFLAGS+=-I${.CURDIR} +YFLAGS= +WARNS?= 2 +WFORMAT=0 + +DPADD= ${LIBUTIL} ${LIBCRYPT} +LDADD= -lutil -lcrypt + +# XXX Kluge! Conversation mechanism needs to be fixed. +DPADD+= ${LIBOPIE} ${LIBMD} +LDADD+= -lopie -lmd + +LSDIR= ../../bin/ls +.PATH: ${.CURDIR}/${LSDIR} +SRCS+= ls.c cmp.c print.c util.c +CFLAGS+=-Dmain=ls_main -I${.CURDIR}/${LSDIR} +DPADD+= ${LIBM} +LDADD+= -lm + +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+=-DINET6 +.endif + +.if ${MK_PAM_SUPPORT} != "no" +CFLAGS+=-DUSE_PAM +DPADD+= ${LIBPAM} +LDADD+= ${MINUSLPAM} +.endif + +.include Added: haiku/vendor/freebsd/current/ftpd/config.h =================================================================== --- haiku/vendor/freebsd/current/ftpd/config.h 2008-02-03 16:20:16 UTC (rev 23840) +++ haiku/vendor/freebsd/current/ftpd/config.h 2008-02-03 16:34:29 UTC (rev 23841) @@ -0,0 +1,281 @@ +/* $FreeBSD: src/libexec/ftpd/config.h,v 1.1 2001/07/19 17:45:14 obrien Exp $ */ + + +/* config.h. Generated automatically by configure. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ +/* $Id: config.h.in,v 1.15 2001/04/28 07:11:46 lukem Exp $ */ + + +/* Define if the closedir function returns void instead of int. */ +/* #undef CLOSEDIR_VOID */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */ +/* #undef F77_NO_MINUS_C_MINUS_O */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to the type of arg1 for select(). */ +/* #undef SELECT_TYPE_ARG1 */ + +/* Define to the type of args 2, 3 and 4 for select(). */ +/* #undef SELECT_TYPE_ARG234 */ + +/* Define to the type of arg5 for select(). */ +/* #undef SELECT_TYPE_ARG5 */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define if the closedir function returns void instead of int. */ +/* #undef VOID_CLOSEDIR */ + +/* The number of bytes in a off_t. */ +#define SIZEOF_OFF_T 0 + +/* Define if you have the err function. */ +#define HAVE_ERR 1 + +/* Define if you have the fgetln function. */ +#define HAVE_FGETLN 1 + +/* Define if you have the flock function. */ +#define HAVE_FLOCK 1 + +/* Define if you have the fparseln function. */ +#define HAVE_FPARSELN 1 + +/* Define if you have the fts_open function. */ +#define HAVE_FTS_OPEN 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define if you have the getgrouplist function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the getspnam function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define if you have the getusershell function. */ +#define HAVE_GETUSERSHELL 1 + +/* Define if you have the inet_net_pton function. */ +#define HAVE_INET_NET_PTON 1 + +/* Define if you have the inet_ntop function. */ +#define HAVE_INET_NTOP 1 + +/* Define if you have the inet_pton function. */ +#define HAVE_INET_PTON 1 + +/* Define if you have the lockf function. */ +#define HAVE_LOCKF 1 + +/* Define if you have the mkstemp function. */ +#define HAVE_MKSTEMP 1 + +/* Define if you have the setlogin function. */ +#define HAVE_SETLOGIN 1 + +/* Define if you have the setproctitle function. */ +#define HAVE_SETPROCTITLE 1 + +/* Define if you have the sl_init function. */ +#define HAVE_SL_INIT 1 + +/* Define if you have the snprintf function. */ +#define HAVE_SNPRINTF 1 + +/* Define if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strlcat function. */ +#define HAVE_STRLCAT 1 + +/* Define if you have the strlcpy function. */ +#define HAVE_STRLCPY 1 + +/* Define if you have the strmode function. */ +#define HAVE_STRMODE 1 + +/* Define if you have the strsep function. */ +#define HAVE_STRSEP 1 + +/* Define if you have the strtoll function. */ +#define HAVE_STRTOLL 1 + +/* Define if you have the user_from_uid function. */ +#define HAVE_USER_FROM_UID 1 + +/* Define if you have the usleep function. */ +#define HAVE_USLEEP 1 + +/* Define if you have the vfork function. */ +#define HAVE_VFORK 1 + +/* Define if you have the vsyslog function. */ +#define HAVE_VSYSLOG 1 + +/* Define if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_ERR_H 1 + +/* Define if you have the header file. */ +#define HAVE_FTS_H 1 + +/* Define if you have the header file. */ +#define HAVE_LIBUTIL_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the header file. */ +#define HAVE_PATHS_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_DIR_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SYSMACROS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_UTIL_H */ + +/* Define if you have the crypt library (-lcrypt). */ +#define HAVE_LIBCRYPT 1 + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the skey library (-lskey). */ +/* #undef HAVE_LIBSKEY */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define if you have the util library (-lutil). */ +#define HAVE_LIBUTIL 1 + +/* Define if your compiler supports `long long' */ +#define HAVE_LONG_LONG 1 + +/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */ +#define HAVE_PRINTF_QD 1 + +/* Define if in_port_t exists */ +#define HAVE_IN_PORT_T 1 + +/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */ +#define HAVE_SOCKADDR_SA_LEN 1 + +/* Define if socklen_t exists */ +#define HAVE_SOCKLEN_T 1 + +/* Define if AF_INET6 exists in */ +#define HAVE_AF_INET6 1 + +/* Define if `struct sockaddr_in6' exists in */ +#define HAVE_SOCKADDR_IN6 1 + +/* Define if `struct addrinfo' exists in */ +#define HAVE_ADDRINFO 1 + +/* + * Define if contains AI_NUMERICHOST et al. + * Systems which only implement RFC2133 will need this. + */ +#define HAVE_RFC2553_NETDB 1 + +/* Define if `struct direct' has a d_namlen element */ +#define HAVE_D_NAMLEN 1 + +/* Define if struct passwd.pw_expire exists. */ +#define HAVE_PW_EXPIRE 1 + +/* Define if GLOB_BRACE, gl_path and gl_match exist in */ +#define HAVE_WORKING_GLOB 1 + +/* Define if crypt() is declared in */ +#define HAVE_CRYPT_D 1 + +/* Define if fclose() is declared in */ +#define HAVE_FCLOSE_D 1 + +/* Define if optarg is declared in or */ +#define HAVE_OPTARG_D 1 + +/* Define if optind is declared in or */ +#define HAVE_OPTIND_D 1 + +/* Define if optreset exists */ +#define HAVE_OPTRESET 1 + +/* Define if pclose() is declared in */ +#define HAVE_PCLOSE_D 1 + +/* Define if getusershell() is declared in */ +#define HAVE_GETUSERSHELL_D 1 + +/* Define if `long long' is supported and sizeof(off_t) >= 8 */ +#define HAVE_QUAD_SUPPORT 1 + +/* Define if not using in-built /bin/ls code */ +/* #undef NO_INTERNAL_LS */ + +/* Define if using S/Key */ +/* #undef SKEY */ + +/* + * Define this if compiling with SOCKS (the firewall traversal library). + * Also, you must define connect, getsockname, bind, accept, listen, and + * select to their R-versions. + */ +/* #undef SOCKS */ +/* #undef SOCKS4 */ +/* #undef SOCKS5 */ +/* #undef connect */ +/* #undef getsockname */ +/* #undef bind */ +/* #undef accept */ +/* #undef listen */ +/* #undef select */ +/* #undef dup */ +/* #undef dup2 */ +/* #undef fclose */ +/* #undef gethostbyname */ +/* #undef getpeername */ +/* #undef read */ +/* #undef recv */ +/* #undef recvfrom */ +/* #undef rresvport */ +/* #undef send */ +/* #undef sendto */ +/* #undef shutdown */ +/* #undef write */ + +/* Define if you have the header file. */ +#define HAVE_FTP_NAMES 1 Added: haiku/vendor/freebsd/current/ftpd/extern.h =================================================================== --- haiku/vendor/freebsd/current/ftpd/extern.h 2008-02-03 16:20:16 UTC (rev 23840) +++ haiku/vendor/freebsd/current/ftpd/extern.h 2008-02-03 16:34:29 UTC (rev 23841) @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)extern.h 8.2 (Berkeley) 4/4/94 + * $FreeBSD: src/libexec/ftpd/extern.h,v 1.19 2002/02/04 01:23:44 kris Exp $ + */ + +#include +#include + +void blkfree(char **); +char **copyblk(char **); +void cwd(char *); +void delete(char *); +void dologout(int); +void fatalerror(char *); +void ftpd_logwtmp(char *, char *, struct sockaddr *addr); +int ftpd_pclose(FILE *); +FILE *ftpd_popen(char *, char *); +char *getline(char *, int, FILE *); +void lreply(int, const char *, ...) __printflike(2, 3); +void makedir(char *); +void nack(char *); +void pass(char *); +void passive(void); +void long_passive(char *, int); +void perror_reply(int, char *); +void pwd(void); +void removedir(char *); +void renamecmd(char *, char *); +char *renamefrom(char *); +void reply(int, const char *, ...) __printflike(2, 3); +void retrieve(char *, char *); +void send_file_list(char *); +#ifdef OLD_SETPROCTITLE +void setproctitle(const char *, ...); +#endif +void statcmd(void); +void statfilecmd(char *); +void store(char *, char *, int); +void upper(char *); +void user(char *); +void yyerror(char *); +int yyparse(void); +int ls_main(int, char **); + +struct sockaddr_in; +struct sockaddr_in6; +union sockunion { + struct sockinet { + u_char si_len; + u_char si_family; + u_short si_port; + } su_si; + struct sockaddr_in su_sin; + struct sockaddr_in6 su_sin6; +}; +#define su_len su_si.si_len +#define su_family su_si.si_family +#define su_port su_si.si_port Added: haiku/vendor/freebsd/current/ftpd/ftpchroot.5 =================================================================== --- haiku/vendor/freebsd/current/ftpd/ftpchroot.5 2008-02-03 16:20:16 UTC (rev 23840) +++ haiku/vendor/freebsd/current/ftpd/ftpchroot.5 2008-02-03 16:34:29 UTC (rev 23841) @@ -0,0 +1,120 @@ +.\" Copyright (c) 2003 FreeBSD Project +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: src/libexec/ftpd/ftpchroot.5,v 1.3 2003/06/01 19:52:36 ru Exp $ +.\" +.Dd January 26, 2003 +.Dt FTPCHROOT 5 +.Os +.Sh NAME +.Nm ftpchroot +.Nd "list users and groups subject to FTP access restrictions" +.Sh DESCRIPTION +The file +.Nm +is read by +.Xr ftpd 8 +at the beginning of an FTP session, after having authenticated the user. +Each line in +.Nm +corresponds to a user or group. +If a line in +.Nm +matches the current user or a group he is a member of, +access restrictions will be applied to this +session by changing its root directory with +.Xr chroot 2 +to that specified on the line or to the user's login directory. +.Pp +The order of records in +.Nm +is important because the first match will be used. +Fields on each line are separated by tabs or spaces. +.Pp +The first field specifies a user or group name. +If it is prefixed by an +.Dq at +sign, +.Ql @ , +it specifies a group name; +the line will match each user who is a member of this group. +As a special case, a single +.Ql @ +in this field will match any user. +A username is specified otherwise. +.Pp +The optional second field describes the directory for the user +or each member of the group to be locked up in using +.Xr chroot 2 . +Be it omitted, the user's login directory will be used. +If it is not an absolute pathname, then it will be relative +to the user's login directory. +If it contains the +.Pa /./ +separator, +.Xr ftpd 8 +will treat its left-hand side as the name of the directory to do +.Xr chroot 2 +to, and its right-hand side to change the current directory to afterwards. +.Sh FILES +.Bl -tag -width ".Pa /etc/ftpchroot" -compact +.It Pa /etc/ftpchroot +.El +.Sh EXAMPLES +These lines in +.Nm +will lock up the user +.Dq Li webuser +and each member of the group +.Dq Li hostee +in their respective login directories: +.Bd -literal -offset indent +webuser + at hostee +.Ed +.Pp +And this line will tell +.Xr ftpd 8 +to lock up the user +.Dq Li joe +in +.Pa /var/spool/ftp +and then to change the current directory to +.Pa /joe , +which is relative to the session's new root: +.Pp +.Dl "joe /var/spool/ftp/./joe" +.Pp +And finally the following line will lock up every user connecting +through FTP in his respective +.Pa ~/public_html , +thus lowering possible impact on the system +from intrinsic insecurity of FTP: +.Pp +.Dl "@ public_html" +.Sh SEE ALSO +.Xr chroot 2 , +.Xr group 5 , +.Xr passwd 5 , +.Xr ftpd 8 Added: haiku/vendor/freebsd/current/ftpd/ftpcmd.y =================================================================== --- haiku/vendor/freebsd/current/ftpd/ftpcmd.y 2008-02-03 16:20:16 UTC (rev 23840) +++ haiku/vendor/freebsd/current/ftpd/ftpcmd.y 2008-02-03 16:34:29 UTC (rev 23841) @@ -0,0 +1,1828 @@ +/* + * Copyright (c) 1985, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ftpcmd.y 8.3 (Berkeley) 4/6/94 + */ + +/* + * Grammar for FTP commands. + * See RFC 959. + */ + +%{ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; +#endif +#endif /* not lint */ + +#include +__FBSDID("$FreeBSD: src/libexec/ftpd/ftpcmd.y,v 1.66 2007/04/18 22:43:39 yar Exp $"); + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "extern.h" +#include "pathnames.h" + +extern union sockunion data_dest, his_addr; +extern int hostinfo; +extern int logged_in; +extern struct passwd *pw; +extern int guest; +extern char *homedir; +extern int paranoid; +extern int logging; +extern int type; +extern int form; +extern int ftpdebug; +extern int timeout; +extern int maxtimeout; +extern int pdata; +extern char *hostname; +extern char proctitle[]; +extern int usedefault; +extern char tmpline[]; +extern int readonly; +extern int assumeutf8; +extern int noepsv; +extern int noretr; +extern int noguestretr; +extern char *typenames[]; /* defined in included from ftpd.c */ + +off_t restart_point; + +static int cmd_type; +static int cmd_form; +static int cmd_bytesz; +static int state; +char cbuf[512]; +char *fromname = NULL; + +extern int epsvall; + +%} + +%union { + struct { + off_t o; + int i; + } u; + char *s; +} + +%token + A B C E F I + L N P R S T + ALL + + SP CRLF COMMA + + USER PASS ACCT REIN QUIT PORT + PASV TYPE STRU MODE RETR STOR + APPE MLFL MAIL MSND MSOM MSAM + MRSQ MRCP ALLO REST RNFR RNTO + ABOR DELE CWD LIST NLST SITE + STAT HELP NOOP MKD RMD PWD + CDUP STOU SMNT SYST SIZE MDTM + LPRT LPSV EPRT EPSV FEAT + + UMASK IDLE CHMOD MDFIVE + + LEXERR NOTIMPL + +%token STRING +%token NUMBER + +%type check_login octal_number byte_size +%type check_login_ro check_login_epsv +%type struct_code mode_code type_code form_code +%type pathstring pathname password username +%type ALL NOTIMPL + +%start cmd_list + +%% + +cmd_list + : /* empty */ + | cmd_list cmd + { + if (fromname) + free(fromname); + fromname = NULL; + restart_point = 0; + } + | cmd_list rcmd + ; + +cmd + : USER SP username CRLF + { + user($3); + free($3); + } + | PASS SP password CRLF + { + pass($3); + free($3); + } + | PASS CRLF + { + pass(""); + } + | PORT check_login SP host_port CRLF + { + if (epsvall) { + reply(501, "No PORT allowed after EPSV ALL."); + goto port_done; + } + if (!$2) + goto port_done; + if (port_check("PORT") == 1) + goto port_done; +#ifdef INET6 + if ((his_addr.su_family != AF_INET6 || + !IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))) { + /* shoud never happen */ + usedefault = 1; + reply(500, "Invalid address rejected."); + goto port_done; + } + port_check_v6("pcmd"); +#endif + port_done: + ; + } + | LPRT check_login SP host_long_port CRLF + { + if (epsvall) { + reply(501, "No LPRT allowed after EPSV ALL."); + goto lprt_done; + } + if (!$2) + goto lprt_done; + if (port_check("LPRT") == 1) + goto lprt_done; +#ifdef INET6 + if (his_addr.su_family != AF_INET6) { + usedefault = 1; + reply(500, "Invalid address rejected."); + goto lprt_done; + } + if (port_check_v6("LPRT") == 1) + goto lprt_done; +#endif + lprt_done: + ; + } + | EPRT check_login SP STRING CRLF + { + char delim; + char *tmp = NULL; + char *p, *q; + char *result[3]; + struct addrinfo hints; + struct addrinfo *res; + int i; + + if (epsvall) { + reply(501, "No EPRT allowed after EPSV ALL."); + goto eprt_done; + } + if (!$2) + goto eprt_done; + + memset(&data_dest, 0, sizeof(data_dest)); + tmp = strdup($4); + if (ftpdebug) + syslog(LOG_DEBUG, "%s", tmp); + if (!tmp) { + fatalerror("not enough core"); + /*NOTREACHED*/ + } + p = tmp; + delim = p[0]; + p++; + memset(result, 0, sizeof(result)); + for (i = 0; i < 3; i++) { + q = strchr(p, delim); + if (!q || *q != delim) { + parsefail: + reply(500, + "Invalid argument, rejected."); + if (tmp) + free(tmp); + usedefault = 1; + goto eprt_done; + } + *q++ = '\0'; + result[i] = p; + if (ftpdebug) + syslog(LOG_DEBUG, "%d: %s", i, p); + p = q; + } + + /* some more sanity check */ + p = result[0]; + while (*p) { + if (!isdigit(*p)) + goto parsefail; + p++; + } + p = result[2]; + while (*p) { + if (!isdigit(*p)) + goto parsefail; + p++; + } + + /* grab address */ + memset(&hints, 0, sizeof(hints)); + if (atoi(result[0]) == 1) + hints.ai_family = PF_INET; +#ifdef INET6 + else if (atoi(result[0]) == 2) + hints.ai_family = PF_INET6; +#endif + else + hints.ai_family = PF_UNSPEC; /*XXX*/ + hints.ai_socktype = SOCK_STREAM; + i = getaddrinfo(result[1], result[2], &hints, &res); + if (i) + goto parsefail; + memcpy(&data_dest, res->ai_addr, res->ai_addrlen); +#ifdef INET6 + if (his_addr.su_family == AF_INET6 + && data_dest.su_family == AF_INET6) { + /* XXX more sanity checks! */ + data_dest.su_sin6.sin6_scope_id = + his_addr.su_sin6.sin6_scope_id; + } +#endif + free(tmp); + tmp = NULL; + + if (port_check("EPRT") == 1) + goto eprt_done; +#ifdef INET6 + if (his_addr.su_family != AF_INET6) { + usedefault = 1; + reply(500, "Invalid address rejected."); + goto eprt_done; + } + if (port_check_v6("EPRT") == 1) + goto eprt_done; +#endif + eprt_done: + free($4); + } + | PASV check_login CRLF + { + if (epsvall) + reply(501, "No PASV allowed after EPSV ALL."); + else if ($2) + passive(); + } + | LPSV check_login CRLF + { + if (epsvall) + reply(501, "No LPSV allowed after EPSV ALL."); + else if ($2) + long_passive("LPSV", PF_UNSPEC); + } + | EPSV check_login_epsv SP NUMBER CRLF + { + if ($2) { + int pf; + switch ($4.i) { + case 1: + pf = PF_INET; + break; +#ifdef INET6 + case 2: + pf = PF_INET6; + break; +#endif + default: + pf = -1; /*junk value*/ + break; + } + long_passive("EPSV", pf); + } + } + | EPSV check_login_epsv SP ALL CRLF + { + if ($2) { + reply(200, "EPSV ALL command successful."); + epsvall++; + } + } + | EPSV check_login_epsv CRLF + { + if ($2) + long_passive("EPSV", PF_UNSPEC); + } + | TYPE check_login SP type_code CRLF + { + if ($2) { + switch (cmd_type) { + + case TYPE_A: + if (cmd_form == FORM_N) { + reply(200, "Type set to A."); + type = cmd_type; + form = cmd_form; + } else + reply(504, "Form must be N."); + break; + + case TYPE_E: + reply(504, "Type E not implemented."); + break; + + case TYPE_I: + reply(200, "Type set to I."); + type = cmd_type; + break; + + case TYPE_L: +#if CHAR_BIT == 8 + if (cmd_bytesz == 8) { + reply(200, + "Type set to L (byte size 8)."); + type = cmd_type; + } else + reply(504, "Byte size must be 8."); +#else /* CHAR_BIT == 8 */ + UNIMPLEMENTED for CHAR_BIT != 8 +#endif /* CHAR_BIT == 8 */ + } + } + } + | STRU check_login SP struct_code CRLF + { + if ($2) { + switch ($4) { + + case STRU_F: + reply(200, "STRU F accepted."); + break; + + default: + reply(504, "Unimplemented STRU type."); + } + } + } + | MODE check_login SP mode_code CRLF + { + if ($2) { + switch ($4) { + + case MODE_S: + reply(200, "MODE S accepted."); + break; + + default: + reply(502, "Unimplemented MODE type."); + } + } + } [... truncated: 6308 lines follow ...] From axeld at mail.berlios.de Sun Feb 3 17:35:06 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 17:35:06 +0100 Subject: [Haiku-commits] r23842 - haiku/vendor/freebsd/RELENG_7_BP Message-ID: <200802031635.m13GZ6MC006539@sheep.berlios.de> Author: axeld Date: 2008-02-03 17:35:06 +0100 (Sun, 03 Feb 2008) New Revision: 23842 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23842&view=rev Added: haiku/vendor/freebsd/RELENG_7_BP/ftpd/ Log: Tagged RELENG_7_BP of ftpd. Copied: haiku/vendor/freebsd/RELENG_7_BP/ftpd (from rev 23841, haiku/vendor/freebsd/current/ftpd) From axeld at mail.berlios.de Sun Feb 3 17:37:52 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 17:37:52 +0100 Subject: [Haiku-commits] r23843 - in haiku/trunk: build/jam data/settings/network src/bin/network src/bin/network/ftpd Message-ID: <200802031637.m13Gbqkv006823@sheep.berlios.de> Author: axeld Date: 2008-02-03 17:37:49 +0100 (Sun, 03 Feb 2008) New Revision: 23843 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23843&view=rev Added: haiku/trunk/src/bin/network/ftpd/ haiku/trunk/src/bin/network/ftpd/Jamfile haiku/trunk/src/bin/network/ftpd/config.h haiku/trunk/src/bin/network/ftpd/extern.h haiku/trunk/src/bin/network/ftpd/ftpcmd.y haiku/trunk/src/bin/network/ftpd/ftpd.c haiku/trunk/src/bin/network/ftpd/logwtmp.c haiku/trunk/src/bin/network/ftpd/md5.h haiku/trunk/src/bin/network/ftpd/md5c.c haiku/trunk/src/bin/network/ftpd/md5hl.c haiku/trunk/src/bin/network/ftpd/pathnames.h haiku/trunk/src/bin/network/ftpd/popen.c Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/data/settings/network/services haiku/trunk/src/bin/network/Jamfile Log: * Ported FreeBSD's ftpd to Haiku. * Added it to the image, and configured it to be used. * Currently, it cannot transfer files over 64 KB for some reason ("Message too long"). Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/build/jam/HaikuImage 2008-02-03 16:37:49 UTC (rev 23843) @@ -28,7 +28,8 @@ cp copyattr $(X86_ONLY)CortexAddOnHost csplit ctags cut date dc dd desklink df diff diff3 dircolors dirname driveinfo dstcheck du echo eject env error expand expr - expr factor false fdinfo ffm find finddir fmt fold fortune frcode ftp funzip fwcontrol + expr factor false fdinfo ffm find finddir fmt fold fortune frcode ftp ftpd + funzip fwcontrol gawk $(X86_ONLY)gdb grep groups gzip gzexe hd head hey hostname id ident ideinfo idestatus ifconfig install installsound iroster isvolume join keymap kill less lessecho lesskey link listarea listattr listdev listimage Modified: haiku/trunk/data/settings/network/services =================================================================== --- haiku/trunk/data/settings/network/services 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/data/settings/network/services 2008-02-03 16:37:49 UTC (rev 23843) @@ -1,3 +1,7 @@ service telnet { launch telnetd } + +service ftp { + launch ftpd +} Modified: haiku/trunk/src/bin/network/Jamfile =================================================================== --- haiku/trunk/src/bin/network/Jamfile 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/src/bin/network/Jamfile 2008-02-03 16:37:49 UTC (rev 23843) @@ -3,6 +3,7 @@ SubInclude HAIKU_TOP src bin network arp ; SubInclude HAIKU_TOP src bin network atftpd ; SubInclude HAIKU_TOP src bin network ftp ; +SubInclude HAIKU_TOP src bin network ftpd ; SubInclude HAIKU_TOP src bin network ifconfig ; SubInclude HAIKU_TOP src bin network login ; SubInclude HAIKU_TOP src bin network mount_nfs ; Added: haiku/trunk/src/bin/network/ftpd/Jamfile =================================================================== --- haiku/trunk/src/bin/network/ftpd/Jamfile 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/src/bin/network/ftpd/Jamfile 2008-02-03 16:37:49 UTC (rev 23843) @@ -0,0 +1,24 @@ +SubDir HAIKU_TOP src bin network ftpd ; + +SetSubDirSupportedPlatforms $(HAIKU_BONE_COMPATIBLE_PLATFORMS) ; + +if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { + UseHeaders [ FDirName $(HAIKU_TOP) headers posix ] : true ; + # We need the public network headers also when not compiling for Haiku. + # Unfortunately we get more than we want, namely all POSIX headers. +} + +UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; +UseHeaders $(SUBDIR) : true ; + +BinCommand ftpd : + ftpd.c + ftpcmd.y + logwtmp.c + popen.c + + # from libmd + md5c.c + md5hl.c + : libutil.a libbsd.so $(TARGET_NETWORK_LIBS) +; Added: haiku/trunk/src/bin/network/ftpd/config.h =================================================================== --- haiku/trunk/src/bin/network/ftpd/config.h 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/src/bin/network/ftpd/config.h 2008-02-03 16:37:49 UTC (rev 23843) @@ -0,0 +1,284 @@ +/* $FreeBSD: src/libexec/ftpd/config.h,v 1.1 2001/07/19 17:45:14 obrien Exp $ */ + + +/* config.h. Generated automatically by configure. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ +/* $Id: config.h.in,v 1.15 2001/04/28 07:11:46 lukem Exp $ */ + + +/* Define if the closedir function returns void instead of int. */ +/* #undef CLOSEDIR_VOID */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */ +/* #undef F77_NO_MINUS_C_MINUS_O */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to the type of arg1 for select(). */ +/* #undef SELECT_TYPE_ARG1 */ + +/* Define to the type of args 2, 3 and 4 for select(). */ +/* #undef SELECT_TYPE_ARG234 */ + +/* Define to the type of arg5 for select(). */ +/* #undef SELECT_TYPE_ARG5 */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define if the closedir function returns void instead of int. */ +/* #undef VOID_CLOSEDIR */ + +/* The number of bytes in a off_t. */ +#define SIZEOF_OFF_T 0 + +/* Define if you have the err function. */ +#define HAVE_ERR 1 + +/* Define if you have the fgetln function. */ +#define HAVE_FGETLN 1 + +/* Define if you have the flock function. */ +#define HAVE_FLOCK 1 + +/* Define if you have the fparseln function. */ +#define HAVE_FPARSELN 1 + +/* Define if you have the fts_open function. */ +#define HAVE_FTS_OPEN 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define if you have the getgrouplist function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the getspnam function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define if you have the getusershell function. */ +#define HAVE_GETUSERSHELL 1 + +/* Define if you have the inet_net_pton function. */ +#define HAVE_INET_NET_PTON 1 + +/* Define if you have the inet_ntop function. */ +#define HAVE_INET_NTOP 1 + +/* Define if you have the inet_pton function. */ +#define HAVE_INET_PTON 1 + +/* Define if you have the lockf function. */ +#define HAVE_LOCKF 1 + +/* Define if you have the mkstemp function. */ +#define HAVE_MKSTEMP 1 + +/* Define if you have the setlogin function. */ +#define HAVE_SETLOGIN 1 + +/* Define if you have the setproctitle function. */ +#define HAVE_SETPROCTITLE 1 + +/* Define if you have the sl_init function. */ +#define HAVE_SL_INIT 1 + +/* Define if you have the snprintf function. */ +#define HAVE_SNPRINTF 1 + +/* Define if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strlcat function. */ +#define HAVE_STRLCAT 1 + +/* Define if you have the strlcpy function. */ +#define HAVE_STRLCPY 1 + +/* Define if you have the strmode function. */ +#define HAVE_STRMODE 1 + +/* Define if you have the strsep function. */ +#define HAVE_STRSEP 1 + +/* Define if you have the strtoll function. */ +#define HAVE_STRTOLL 1 + +/* Define if you have the user_from_uid function. */ +#define HAVE_USER_FROM_UID 1 + +/* Define if you have the usleep function. */ +#define HAVE_USLEEP 1 + +/* Define if you have the vfork function. */ +#define HAVE_VFORK 1 + +/* Define if you have the vsyslog function. */ +#define HAVE_VSYSLOG 1 + +/* Define if you have the header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_ERR_H 1 + +/* Define if you have the header file. */ +#define HAVE_FTS_H 1 + +/* Define if you have the header file. */ +#define HAVE_LIBUTIL_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the header file. */ +#define HAVE_PATHS_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_DIR_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SYSMACROS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_UTIL_H */ + +/* Define if you have the crypt library (-lcrypt). */ +#define HAVE_LIBCRYPT 1 + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the skey library (-lskey). */ +/* #undef HAVE_LIBSKEY */ + +/* Define if you have the opie library (-lopie). */ +/* #undef HAVE_LIBOPIE */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define if you have the util library (-lutil). */ +#define HAVE_LIBUTIL 1 + +/* Define if your compiler supports `long long' */ +#define HAVE_LONG_LONG 1 + +/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */ +#define HAVE_PRINTF_QD 1 + +/* Define if in_port_t exists */ +#define HAVE_IN_PORT_T 1 + +/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */ +#define HAVE_SOCKADDR_SA_LEN 1 + +/* Define if socklen_t exists */ +#define HAVE_SOCKLEN_T 1 + +/* Define if AF_INET6 exists in */ +/* #define HAVE_AF_INET6 1 */ + +/* Define if `struct sockaddr_in6' exists in */ +#define HAVE_SOCKADDR_IN6 1 + +/* Define if `struct addrinfo' exists in */ +#define HAVE_ADDRINFO 1 + +/* + * Define if contains AI_NUMERICHOST et al. + * Systems which only implement RFC2133 will need this. + */ +#define HAVE_RFC2553_NETDB 1 + +/* Define if `struct direct' has a d_namlen element */ +#define HAVE_D_NAMLEN 1 + +/* Define if struct passwd.pw_expire exists. */ +#define HAVE_PW_EXPIRE 1 + +/* Define if GLOB_BRACE, gl_path and gl_match exist in */ +#define HAVE_WORKING_GLOB 1 + +/* Define if crypt() is declared in */ +#define HAVE_CRYPT_D 1 + +/* Define if fclose() is declared in */ +#define HAVE_FCLOSE_D 1 + +/* Define if optarg is declared in or */ +#define HAVE_OPTARG_D 1 + +/* Define if optind is declared in or */ +#define HAVE_OPTIND_D 1 + +/* Define if optreset exists */ +#define HAVE_OPTRESET 1 + +/* Define if pclose() is declared in */ +#define HAVE_PCLOSE_D 1 + +/* Define if getusershell() is declared in */ +#define HAVE_GETUSERSHELL_D 1 + +/* Define if `long long' is supported and sizeof(off_t) >= 8 */ +#define HAVE_QUAD_SUPPORT 1 + +/* Define if not using in-built /bin/ls code */ +/* #undef NO_INTERNAL_LS */ + +/* Define if using S/Key */ +/* #undef SKEY */ + +/* + * Define this if compiling with SOCKS (the firewall traversal library). + * Also, you must define connect, getsockname, bind, accept, listen, and + * select to their R-versions. + */ +/* #undef SOCKS */ +/* #undef SOCKS4 */ +/* #undef SOCKS5 */ +/* #undef connect */ +/* #undef getsockname */ +/* #undef bind */ +/* #undef accept */ +/* #undef listen */ +/* #undef select */ +/* #undef dup */ +/* #undef dup2 */ +/* #undef fclose */ +/* #undef gethostbyname */ +/* #undef getpeername */ +/* #undef read */ +/* #undef recv */ +/* #undef recvfrom */ +/* #undef rresvport */ +/* #undef send */ +/* #undef sendto */ +/* #undef shutdown */ +/* #undef write */ + +/* Define if you have the header file. */ +#define HAVE_FTP_NAMES 1 Added: haiku/trunk/src/bin/network/ftpd/extern.h =================================================================== --- haiku/trunk/src/bin/network/ftpd/extern.h 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/src/bin/network/ftpd/extern.h 2008-02-03 16:37:49 UTC (rev 23843) @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)extern.h 8.2 (Berkeley) 4/4/94 + * $FreeBSD: src/libexec/ftpd/extern.h,v 1.19 2002/02/04 01:23:44 kris Exp $ + */ + +#include +#include + +void blkfree(char **); +char **copyblk(char **); +void cwd(char *); +void delete(char *); +void dologout(int); +void fatalerror(char *); +void ftpd_logwtmp(char *, char *, struct sockaddr *addr); +int ftpd_pclose(FILE *); +FILE *ftpd_popen(char *, char *); +char *getline(char *, int, FILE *); +void lreply(int, const char *, ...) __printflike(2, 3); +void makedir(char *); +void nack(char *); +void pass(char *); +void passive(void); +void long_passive(char *, int); +void perror_reply(int, char *); +void pwd(void); +void removedir(char *); +void renamecmd(char *, char *); +char *renamefrom(char *); +void reply(int, const char *, ...) __printflike(2, 3); +void retrieve(char *, char *); +void send_file_list(char *); +#ifdef OLD_SETPROCTITLE +void setproctitle(const char *, ...); +#endif +void statcmd(void); +void statfilecmd(char *); +void store(char *, char *, int); +void upper(char *); +void user(char *); +void yyerror(char *); +int yyparse(void); +int ls_main(int, char **); + +struct sockaddr_in; +struct sockaddr_in6; +union sockunion { + struct sockinet { + u_char si_len; + u_char si_family; + u_short si_port; + } su_si; + struct sockaddr_in su_sin; + struct sockaddr_in6 su_sin6; +}; +#define su_len su_si.si_len +#define su_family su_si.si_family +#define su_port su_si.si_port Added: haiku/trunk/src/bin/network/ftpd/ftpcmd.y =================================================================== --- haiku/trunk/src/bin/network/ftpd/ftpcmd.y 2008-02-03 16:35:06 UTC (rev 23842) +++ haiku/trunk/src/bin/network/ftpd/ftpcmd.y 2008-02-03 16:37:49 UTC (rev 23843) @@ -0,0 +1,1829 @@ +/* + * Copyright (c) 1985, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ftpcmd.y 8.3 (Berkeley) 4/6/94 + */ + +/* + * Grammar for FTP commands. + * See RFC 959. + */ + +%{ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; +#endif +#endif /* not lint */ + +#include +__FBSDID("$FreeBSD: src/libexec/ftpd/ftpcmd.y,v 1.66 2007/04/18 22:43:39 yar Exp $"); + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "extern.h" +#include "pathnames.h" + +extern union sockunion data_dest, his_addr; +extern int hostinfo; +extern int logged_in; +extern struct passwd *pw; +extern int guest; +extern char *homedir; +extern int paranoid; +extern int logging; +extern int type; +extern int form; +extern int ftpdebug; +extern int timeout; +extern int maxtimeout; +extern int pdata; +extern char *hostname; +extern char proctitle[]; +extern int usedefault; +extern char tmpline[]; +extern int readonly; +extern int assumeutf8; +extern int noepsv; +extern int noretr; +extern int noguestretr; +extern char *typenames[]; /* defined in included from ftpd.c */ + +off_t restart_point; + +static int cmd_type; +static int cmd_form; +static int cmd_bytesz; +static int state; +char cbuf[512]; +char *fromname = NULL; + +extern int epsvall; + +#define CMD 0 /* beginning of command */ +#define ARGS 1 /* expect miscellaneous arguments */ +#define STR1 2 /* expect SP followed by STRING */ +#define STR2 3 /* expect STRING */ +#define OSTR 4 /* optional SP then STRING */ +#define ZSTR1 5 /* optional SP then optional STRING */ +#define ZSTR2 6 /* optional STRING after SP */ +#define SITECMD 7 /* SITE command */ +#define NSTR 8 /* Number followed by a string */ + +#define MAXGLOBARGS 1000 + +#define MAXASIZE 10240 /* Deny ASCII SIZE on files larger than that */ + +struct tab { + char *name; + short token; + short state; + short implemented; /* 1 if command is implemented */ + char *help; +}; + +struct tab cmdtab[] = { /* In order defined in RFC 765 */ + { "USER", USER, STR1, 1, " username" }, + { "PASS", PASS, ZSTR1, 1, "[ [password]]" }, + { "ACCT", ACCT, STR1, 0, "(specify account)" }, + { "SMNT", SMNT, ARGS, 0, "(structure mount)" }, + { "REIN", REIN, ARGS, 0, "(reinitialize server state)" }, + { "QUIT", QUIT, ARGS, 1, "(terminate service)", }, + { "PORT", PORT, ARGS, 1, " b0, b1, b2, b3, b4, b5" }, + { "LPRT", LPRT, ARGS, 1, " af, hal, h1, h2, h3,..., pal, p1, p2..." }, + { "EPRT", EPRT, STR1, 1, " |af|addr|port|" }, + { "PASV", PASV, ARGS, 1, "(set server in passive mode)" }, + { "LPSV", LPSV, ARGS, 1, "(set server in passive mode)" }, + { "EPSV", EPSV, ARGS, 1, "[ af|ALL]" }, + { "TYPE", TYPE, ARGS, 1, " { A | E | I | L }" }, + { "STRU", STRU, ARGS, 1, "(specify file structure)" }, + { "MODE", MODE, ARGS, 1, "(specify transfer mode)" }, + { "RETR", RETR, STR1, 1, " file-name" }, + { "STOR", STOR, STR1, 1, " file-name" }, + { "APPE", APPE, STR1, 1, " file-name" }, + { "MLFL", MLFL, OSTR, 0, "(mail file)" }, + { "MAIL", MAIL, OSTR, 0, "(mail to user)" }, + { "MSND", MSND, OSTR, 0, "(mail send to terminal)" }, + { "MSOM", MSOM, OSTR, 0, "(mail send to terminal or mailbox)" }, + { "MSAM", MSAM, OSTR, 0, "(mail send to terminal and mailbox)" }, + { "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" }, + { "MRCP", MRCP, STR1, 0, "(mail recipient)" }, + { "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" }, + { "REST", REST, ARGS, 1, " offset (restart command)" }, + { "RNFR", RNFR, STR1, 1, " file-name" }, + { "RNTO", RNTO, STR1, 1, " file-name" }, + { "ABOR", ABOR, ARGS, 1, "(abort operation)" }, + { "DELE", DELE, STR1, 1, " file-name" }, + { "CWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "XCWD", CWD, OSTR, 1, "[ directory-name ]" }, + { "LIST", LIST, OSTR, 1, "[ path-name ]" }, + { "NLST", NLST, OSTR, 1, "[ path-name ]" }, + { "SITE", SITE, SITECMD, 1, "site-cmd [ arguments ]" }, + { "SYST", SYST, ARGS, 1, "(get type of operating system)" }, + { "FEAT", FEAT, ARGS, 1, "(get extended features)" }, + { "STAT", STAT, OSTR, 1, "[ path-name ]" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { "NOOP", NOOP, ARGS, 1, "" }, + { "MKD", MKD, STR1, 1, " path-name" }, + { "XMKD", MKD, STR1, 1, " path-name" }, + { "RMD", RMD, STR1, 1, " path-name" }, + { "XRMD", RMD, STR1, 1, " path-name" }, + { "PWD", PWD, ARGS, 1, "(return current directory)" }, + { "XPWD", PWD, ARGS, 1, "(return current directory)" }, + { "CDUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "XCUP", CDUP, ARGS, 1, "(change to parent directory)" }, + { "STOU", STOU, STR1, 1, " file-name" }, + { "SIZE", SIZE, OSTR, 1, " path-name" }, + { "MDTM", MDTM, OSTR, 1, " path-name" }, + { NULL, 0, 0, 0, 0 } +}; + +struct tab sitetab[] = { + { "MD5", MDFIVE, STR1, 1, "[ file-name ]" }, + { "UMASK", UMASK, ARGS, 1, "[ umask ]" }, + { "IDLE", IDLE, ARGS, 1, "[ maximum-idle-time ]" }, + { "CHMOD", CHMOD, NSTR, 1, " mode file-name" }, + { "HELP", HELP, OSTR, 1, "[ ]" }, + { NULL, 0, 0, 0, 0 } +}; + +static char *copy(char *); +static char *expglob(char *); +static char *exptilde(char *); +static void help(struct tab *, char *); +static struct tab * + lookup(struct tab *, char *); +static int port_check(const char *); +#ifdef INET6 +static int port_check_v6(const char *); +#endif +static int check_login1(void); +static void sizecmd(char *); +static void toolong(int); +#ifdef INET6 +static void v4map_data_dest(void); +#endif +static int yylex(void); + +%} + +%union { + struct { + off_t o; + int i; + } u; + char *s; +} + +%token + A B C E F I + L N P R S T + ALL + + SP CRLF COMMA + + USER PASS ACCT REIN QUIT PORT + PASV TYPE STRU MODE RETR STOR + APPE MLFL MAIL MSND MSOM MSAM + MRSQ MRCP ALLO REST RNFR RNTO + ABOR DELE CWD LIST NLST SITE + STAT HELP NOOP MKD RMD PWD + CDUP STOU SMNT SYST SIZE MDTM + LPRT LPSV EPRT EPSV FEAT + + UMASK IDLE CHMOD MDFIVE + + LEXERR NOTIMPL + +%token STRING +%token NUMBER + +%type check_login octal_number byte_size +%type check_login_ro check_login_epsv +%type struct_code mode_code type_code form_code +%type pathstring pathname password username +%type ALL NOTIMPL + +%start cmd_list + +%% + +cmd_list + : /* empty */ + | cmd_list cmd + { + if (fromname) + free(fromname); + fromname = NULL; + restart_point = 0; + } + | cmd_list rcmd + ; + +cmd + : USER SP username CRLF + { + user($3); + free($3); + } + | PASS SP password CRLF + { + pass($3); + free($3); + } + | PASS CRLF + { + pass(""); + } + | PORT check_login SP host_port CRLF + { + if (epsvall) { + reply(501, "No PORT allowed after EPSV ALL."); + goto port_done; + } + if (!$2) + goto port_done; + if (port_check("PORT") == 1) + goto port_done; +#ifdef INET6 + if ((his_addr.su_family != AF_INET6 || + !IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))) { + /* shoud never happen */ + usedefault = 1; + reply(500, "Invalid address rejected."); + goto port_done; + } + port_check_v6("pcmd"); +#endif + port_done: + ; + } + | LPRT check_login SP host_long_port CRLF + { + if (epsvall) { + reply(501, "No LPRT allowed after EPSV ALL."); + goto lprt_done; + } + if (!$2) + goto lprt_done; + if (port_check("LPRT") == 1) + goto lprt_done; +#ifdef INET6 + if (his_addr.su_family != AF_INET6) { + usedefault = 1; + reply(500, "Invalid address rejected."); + goto lprt_done; + } + if (port_check_v6("LPRT") == 1) + goto lprt_done; +#endif + lprt_done: + ; + } + | EPRT check_login SP STRING CRLF + { + char delim; + char *tmp = NULL; + char *p, *q; + char *result[3]; + struct addrinfo hints; + struct addrinfo *res; + int i; + + if (epsvall) { + reply(501, "No EPRT allowed after EPSV ALL."); + goto eprt_done; + } + if (!$2) + goto eprt_done; + + memset(&data_dest, 0, sizeof(data_dest)); + tmp = strdup($4); + if (ftpdebug) + syslog(LOG_DEBUG, "%s", tmp); + if (!tmp) { + fatalerror("not enough core"); + /*NOTREACHED*/ + } + p = tmp; + delim = p[0]; + p++; + memset(result, 0, sizeof(result)); + for (i = 0; i < 3; i++) { + q = strchr(p, delim); + if (!q || *q != delim) { + parsefail: + reply(500, + "Invalid argument, rejected."); + if (tmp) + free(tmp); + usedefault = 1; + goto eprt_done; + } + *q++ = '\0'; + result[i] = p; + if (ftpdebug) + syslog(LOG_DEBUG, "%d: %s", i, p); + p = q; + } + + /* some more sanity check */ + p = result[0]; + while (*p) { + if (!isdigit(*p)) + goto parsefail; + p++; + } + p = result[2]; + while (*p) { + if (!isdigit(*p)) + goto parsefail; + p++; + } + + /* grab address */ + memset(&hints, 0, sizeof(hints)); + if (atoi(result[0]) == 1) + hints.ai_family = PF_INET; +#ifdef INET6 + else if (atoi(result[0]) == 2) + hints.ai_family = PF_INET6; +#endif + else + hints.ai_family = PF_UNSPEC; /*XXX*/ + hints.ai_socktype = SOCK_STREAM; + i = getaddrinfo(result[1], result[2], &hints, &res); + if (i) + goto parsefail; + memcpy(&data_dest, res->ai_addr, res->ai_addrlen); +#ifdef INET6 + if (his_addr.su_family == AF_INET6 + && data_dest.su_family == AF_INET6) { + /* XXX more sanity checks! */ + data_dest.su_sin6.sin6_scope_id = + his_addr.su_sin6.sin6_scope_id; + } +#endif + free(tmp); + tmp = NULL; + + if (port_check("EPRT") == 1) + goto eprt_done; +#ifdef INET6 + if (his_addr.su_family != AF_INET6) { + usedefault = 1; + reply(500, "Invalid address rejected."); + goto eprt_done; + } + if (port_check_v6("EPRT") == 1) + goto eprt_done; +#endif + eprt_done: + free($4); + } + | PASV check_login CRLF + { + if (epsvall) + reply(501, "No PASV allowed after EPSV ALL."); + else if ($2) + passive(); + } + | LPSV check_login CRLF + { + if (epsvall) + reply(501, "No LPSV allowed after EPSV ALL."); + else if ($2) + long_passive("LPSV", PF_UNSPEC); + } + | EPSV check_login_epsv SP NUMBER CRLF + { + if ($2) { + int pf; + switch ($4.i) { + case 1: + pf = PF_INET; + break; +#ifdef INET6 + case 2: + pf = PF_INET6; + break; +#endif + default: + pf = -1; /*junk value*/ + break; + } + long_passive("EPSV", pf); + } + } + | EPSV check_login_epsv SP ALL CRLF + { + if ($2) { + reply(200, "EPSV ALL command successful."); + epsvall++; + } + } + | EPSV check_login_epsv CRLF + { + if ($2) + long_passive("EPSV", PF_UNSPEC); + } + | TYPE check_login SP type_code CRLF + { + if ($2) { + switch (cmd_type) { + + case TYPE_A: + if (cmd_form == FORM_N) { + reply(200, "Type set to A."); + type = cmd_type; + form = cmd_form; + } else + reply(504, "Form must be N."); + break; + + case TYPE_E: + reply(504, "Type E not implemented."); + break; + + case TYPE_I: + reply(200, "Type set to I."); + type = cmd_type; + break; + + case TYPE_L: +#if CHAR_BIT == 8 + if (cmd_bytesz == 8) { + reply(200, + "Type set to L (byte size 8)."); + type = cmd_type; + } else + reply(504, "Byte size must be 8."); +#else /* CHAR_BIT == 8 */ + UNIMPLEMENTED for CHAR_BIT != 8 +#endif /* CHAR_BIT == 8 */ + } + } + } + | STRU check_login SP struct_code CRLF + { + if ($2) { + switch ($4) { + + case STRU_F: + reply(200, "STRU F accepted."); + break; + + default: + reply(504, "Unimplemented STRU type."); + } + } + } + | MODE check_login SP mode_code CRLF + { + if ($2) { + switch ($4) { + + case MODE_S: + reply(200, "MODE S accepted."); [... truncated: 5676 lines follow ...] From axeld at pinc-software.de Sun Feb 3 17:43:34 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 03 Feb 2008 17:43:34 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23838_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/os/drivers_src/system/kernel__src/system/kernel/arch/x8?= =?iso-8859-15?q?6_src/system/kernel/debug?= In-Reply-To: <200802031616.m13GGIpR005054@sheep.berlios.de> Message-ID: <20105392684-BeMail@zon> mmlr at BerliOS wrote: > Probably this flag should be made private though. Nice catch, and +1 for the privacy thing :-) Bye, Axel. From stippi at mail.berlios.de Sun Feb 3 18:25:33 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Feb 2008 18:25:33 +0100 Subject: [Haiku-commits] r23844 - haiku/trunk/src/apps/drivesetup Message-ID: <200802031725.m13HPXml011042@sheep.berlios.de> Author: stippi Date: 2008-02-03 18:25:33 +0100 (Sun, 03 Feb 2008) New Revision: 23844 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23844&view=rev Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp Log: Fixes the build for the app_server test environment. Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-03 16:37:49 UTC (rev 23843) +++ haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-03 17:25:33 UTC (rev 23844) @@ -325,34 +325,34 @@ #ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST PartitionView* view; float scale = 1.0; - view = new PartitionView("Disk", scale, 0, -1); + view = new PartitionView("Disk", scale, 0, 0, -1); layout->AddView(view, scale); layout = view->GroupLayout(); scale = 0.3; - view = new PartitionView("Primary", scale, 1, -1); + view = new PartitionView("Primary", scale, 1, 50, -1); layout->AddView(view, scale); scale = 0.7; - view = new PartitionView("Extended", scale, 1, -1); + view = new PartitionView("Extended", scale, 1, 100, -1); layout->AddView(view, scale); layout = view->GroupLayout(); scale = 0.2; - view = new PartitionView("Logical", scale, 2, -1); + view = new PartitionView("Logical", scale, 2, 200, -1); layout->AddView(view, scale); scale = 0.5; - view = new PartitionView("Logical", scale, 2, -1); + view = new PartitionView("Logical", scale, 2, 250, -1); layout->AddView(view, scale); scale = 0.005; - view = new PartitionView("Logical", scale, 2, -1); + view = new PartitionView("Logical", scale, 2, 290, -1); layout->AddView(view, scale); scale = 0.295; - view = new PartitionView("Logical", scale, 2, -1); + view = new PartitionView("Logical", scale, 2, 420, -1); layout->AddView(view, scale); #endif } From stippi at mail.berlios.de Sun Feb 3 18:29:49 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Feb 2008 18:29:49 +0100 Subject: [Haiku-commits] r23845 - haiku/trunk/src/apps/drivesetup Message-ID: <200802031729.m13HTnjw011307@sheep.berlios.de> Author: stippi Date: 2008-02-03 18:29:48 +0100 (Sun, 03 Feb 2008) New Revision: 23845 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23845&view=rev Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp haiku/trunk/src/apps/drivesetup/PartitionList.cpp haiku/trunk/src/apps/drivesetup/PartitionList.h Log: Incorporate work done by James Urquhart (jamesu): * Use our own BBitmapStringField implementation which also requires our own BColumn implementation. This is just a visual improvement which makes both the eventual partiton icon and device label indent with the outline level of the list item * when setting the Unmount menu item enabled state, check wether the partition in question is the /boot volume and disallow unmounting. Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-03 17:25:33 UTC (rev 23844) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-03 17:29:48 UTC (rev 23845) @@ -29,6 +29,8 @@ #include #include #include +#include +#include class ListPopulatorVisitor : public BDiskDeviceVisitor { @@ -81,9 +83,6 @@ i++) { fPartitionList->AddSpace(partition->ID(), offset, size); } - } else { - fprintf(stderr, "failed to get partitioning info: %s\n", - strerror(ret)); } } @@ -480,7 +479,18 @@ // fDeleteMI->SetEnabled(!partition->IsMounted()); fDeleteMI->SetEnabled(false); fMountMI->SetEnabled(!partition->IsMounted()); - fUnmountMI->SetEnabled(partition->IsMounted()); + + if (partition->IsMounted()) { + // see if this partition is the boot volume + BVolume volume; + BVolume bootVolume; + if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK + && partition->GetVolume(&volume) == B_OK) { + fUnmountMI->SetEnabled(volume != bootVolume); + } else { + fUnmountMI->SetEnabled(true); + } + } } else { fInitMenu->SetEnabled(false); fDeleteMI->SetEnabled(false); Modified: haiku/trunk/src/apps/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-03 17:25:33 UTC (rev 23844) +++ haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-03 17:29:48 UTC (rev 23845) @@ -4,6 +4,7 @@ * * Authors: * Ithamar R. Adema + * James Urquhart * Stephan A?mus */ #include "PartitionList.h" @@ -13,10 +14,132 @@ #include +// #pragma mark - BBitmapStringField + + +BBitmapStringField::BBitmapStringField(BBitmap* bitmap, const char* string) + : Inherited(string) + , fBitmap(bitmap) +{ +} + + +BBitmapStringField::~BBitmapStringField() +{ + delete fBitmap; +} + + +void +BBitmapStringField::SetBitmap(BBitmap* bitmap) +{ + delete fBitmap; + fBitmap = bitmap; + // TODO: cause a redraw? +} + + +// #pragma mark - PartitionColumn + + +float PartitionColumn::fTextMargin = 0.0; + + +PartitionColumn::PartitionColumn(const char* title, float width, float minWidth, + float maxWidth, uint32 truncateMode, alignment align) + : Inherited(title, width, minWidth, maxWidth, align), + fTruncateMode(truncateMode) +{ + SetWantsEvents(true); +} + + +void +PartitionColumn::DrawField(BField* field, BRect rect, BView* parent) +{ + if (fTextMargin == 0.0) { + // we are the first column to draw something and need to + // init the text margin + BFont font; + parent->GetFont(&font); + fTextMargin = ceilf(font.Size() * 0.8); + } + + BBitmapStringField* bitmapField + = dynamic_cast(field); + BStringField* stringField = dynamic_cast(field); + + if (bitmapField) { + const BBitmap* bitmap = bitmapField->Bitmap(); + + // figure out the placement + float x = 0.0; + BRect r = bitmap ? bitmap->Bounds() : BRect(0, 0, 15, 15); + float y = rect.top + ((rect.Height() - r.Height()) / 2); + float width = 0.0; + + switch (Alignment()) { + default: + case B_ALIGN_LEFT: + case B_ALIGN_CENTER: + x = rect.left + fTextMargin; + width = rect.right - (x + r.Width()) - (2 * fTextMargin); + r.Set(x + r.Width(), rect.top, rect.right - width, rect.bottom); + break; + + case B_ALIGN_RIGHT: + x = rect.right - fTextMargin - r.Width(); + width = (x - rect.left - (2 * fTextMargin)); + r.Set(rect.left, rect.top, rect.left + width, rect.bottom); + break; + } + + if (width != bitmapField->Width()) { + BString truncatedString(bitmapField->String()); + parent->TruncateString(&truncatedString, fTruncateMode, width + 2); + bitmapField->SetClippedString(truncatedString.String()); + bitmapField->SetWidth(width); + } + + // draw the bitmap + if (bitmap) { + parent->SetDrawingMode(B_OP_ALPHA); + parent->DrawBitmap(bitmap, BPoint(x, y)); + parent->SetDrawingMode(B_OP_OVER); + } + + // draw the string + DrawString(bitmapField->ClippedString(), parent, r); + + } else if (stringField) { + + float width = rect.Width() - (2 * fTextMargin); + + if (width != stringField->Width()) { + BString truncatedString(stringField->String()); + + parent->TruncateString(&truncatedString, fTruncateMode, width + 2); + stringField->SetClippedString(truncatedString.String()); + stringField->SetWidth(width); + } + + DrawString(stringField->ClippedString(), parent, rect); + } +} + +bool +PartitionColumn::AcceptsField(const BField* field) const +{ + return dynamic_cast(field) != NULL; +} + + +// #pragma mark - PartitionListRow + + static const char* kUnavailableString = ""; enum { -// kBitmapColumn, kDeviceColumn, kFilesystemColumn, kVolumeNameColumn, @@ -32,12 +155,21 @@ , fOffset(partition->Offset()) , fSize(partition->Size()) { -// SetField(new BBitmapField(NULL), kBitmapColumn); - BPath path; partition->GetPath(&path); - SetField(new BStringField(path.Path()), kDeviceColumn); + BBitmap* icon = NULL; + if (partition->IsDevice()) { + icon_size size = B_MINI_ICON; + icon = new BBitmap(BRect(0, 0, size - 1, size - 1), B_RGBA32); + if (partition->GetIcon(icon, size) != B_OK) { + delete icon; + icon = NULL; + } + } + + SetField(new BBitmapStringField(icon, path.Path()), kDeviceColumn); + if (partition->ContainsFileSystem()) { SetField(new BStringField(partition->ContentType()), kFilesystemColumn); SetField(new BStringField(partition->ContentName()), kVolumeNameColumn); @@ -66,11 +198,10 @@ , fOffset(offset) , fSize(size) { -// SetField(new BBitmapField(NULL), kBitmapColumn); + // TODO: design icon for spaces on partitions + SetField(new BBitmapStringField(NULL, "-"), kDeviceColumn); - SetField(new BStringField("-"), kDeviceColumn); - - SetField(new BStringField("Empty"), kFilesystemColumn); + SetField(new BStringField(""), kFilesystemColumn); SetField(new BStringField(kUnavailableString), kVolumeNameColumn); SetField(new BStringField(kUnavailableString), kMountedAtColumn); @@ -83,18 +214,16 @@ PartitionListView::PartitionListView(const BRect& frame, uint32 resizeMode) : Inherited(frame, "storagelist", resizeMode, 0, B_NO_BORDER, true) { -// AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), -// kBitmapColumn); - AddColumn(new BStringColumn("Device", 150, 50, 500, B_TRUNCATE_MIDDLE), - kDeviceColumn); - AddColumn(new BStringColumn("Filesystem", 100, 50, 500, B_TRUNCATE_MIDDLE), - kFilesystemColumn); - AddColumn(new BStringColumn("Volume Name", 130, 50, 500, B_TRUNCATE_MIDDLE), - kVolumeNameColumn); - AddColumn(new BStringColumn("Mounted At", 100, 50, 500, B_TRUNCATE_MIDDLE), - kMountedAtColumn); - AddColumn(new BStringColumn("Size", 100, 50, 500, B_TRUNCATE_END, - B_ALIGN_RIGHT), kSizeColumn); + AddColumn(new PartitionColumn("Device", 150, 50, 500, + B_TRUNCATE_MIDDLE), kDeviceColumn); + AddColumn(new PartitionColumn("Filesystem", 100, 50, 500, + B_TRUNCATE_MIDDLE), kFilesystemColumn); + AddColumn(new PartitionColumn("Volume Name", 130, 50, 500, + B_TRUNCATE_MIDDLE), kVolumeNameColumn); + AddColumn(new PartitionColumn("Mounted At", 100, 50, 500, + B_TRUNCATE_MIDDLE), kMountedAtColumn); + AddColumn(new PartitionColumn("Size", 100, 50, 500, + B_TRUNCATE_END, B_ALIGN_RIGHT), kSizeColumn); SetSortingEnabled(false); } Modified: haiku/trunk/src/apps/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-03 17:25:33 UTC (rev 23844) +++ haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-03 17:29:48 UTC (rev 23845) @@ -4,23 +4,61 @@ * * Authors: * Ithamar R. Adema + * James Urquhart * Stephan A?mus */ #ifndef PARTITIONLIST_H #define PARTITIONLIST_H -class PartitionListRow; -class PartitionListView; - - #include +#include #include class BPartition; +// A field type displaying both a bitmap and a string so that the +// tree display looks nicer (both text and bitmap are indented) +class BBitmapStringField : public BStringField { + typedef BStringField Inherited; +public: + BBitmapStringField(BBitmap* bitmap, + const char* string); + virtual ~BBitmapStringField(); + + void SetBitmap(BBitmap* bitmap); + const BBitmap* Bitmap() const + { return fBitmap; } + +private: + BBitmap* fBitmap; +}; + + +// BColumn for PartitionListView which knows how to render +// a BBitmapStringField +class PartitionColumn : public BTitledColumn { + typedef BTitledColumn Inherited; +public: + PartitionColumn(const char* title, + float width, float minWidth, + float maxWidth, uint32 truncateMode, + alignment align = B_ALIGN_LEFT); + + virtual void DrawField(BField* field, BRect rect, + BView* parent); + + virtual bool AcceptsField(const BField* field) const; + +private: + uint32 fTruncateMode; + static float fTextMargin; +}; + + +// BRow for the PartitionListView class PartitionListRow : public BRow { typedef BRow Inherited; public: @@ -30,6 +68,8 @@ partition_id ID() const { return fPartitionID; } + partition_id ParentID() const + { return fParentID; } off_t Offset() const { return fOffset; } off_t Size() const From axeld at mail.berlios.de Sun Feb 3 18:52:44 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 18:52:44 +0100 Subject: [Haiku-commits] r23846 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802031752.m13Hqi65018100@sheep.berlios.de> Author: axeld Date: 2008-02-03 18:52:43 +0100 (Sun, 03 Feb 2008) New Revision: 23846 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23846&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: Fixed the "call" command to actually show the arguments that belong to the function name it prints. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-02-03 17:29:48 UTC (rev 23845) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-02-03 17:52:43 UTC (rev 23846) @@ -336,7 +336,8 @@ static void -print_call(struct thread *thread, addr_t eip, addr_t ebp, int32 argCount) +print_call(struct thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp, + int32 argCount) { const char *symbol, *image; addr_t baseAddress; @@ -366,7 +367,7 @@ } } - int32 *arg = (int32 *)(ebp + 8); + int32 *arg = (int32 *)(nextEbp + 8); kprintf("("); for (int32 i = 0; i < argCount; i++) { @@ -399,7 +400,7 @@ struct thread *thread = NULL; addr_t oldPageDirectory = 0; - uint32 ebp = x86_read_ebp(); + addr_t ebp = x86_read_ebp(); int32 argCount = 0; if (argc >= 2 && argv[argc - 1][0] == '-') { @@ -426,7 +427,7 @@ bool onKernelStack = true; - for (int32 index = 1; index <= callIndex; index++) { + for (int32 index = 0; index <= callIndex; index++) { onKernelStack = onKernelStack && is_kernel_stack_address(thread, ebp); @@ -434,7 +435,7 @@ struct iframe *frame = (struct iframe *)ebp; if (index == callIndex) - print_call(thread, frame->eip, ebp, argCount); + print_call(thread, frame->eip, ebp, frame->ebp, argCount); ebp = frame->ebp; } else { @@ -449,7 +450,8 @@ break; if (index == callIndex) - print_call(thread, eip, ebp, argCount); + print_call(thread, eip, ebp, nextEbp, argCount); + ebp = nextEbp; } From mmu_man at mail.berlios.de Sun Feb 3 18:53:53 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 18:53:53 +0100 Subject: [Haiku-commits] r23847 - haiku/trunk/src/apps/sudoku Message-ID: <200802031753.m13HrrSH018941@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 18:53:52 +0100 (Sun, 03 Feb 2008) New Revision: 23847 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23847&view=rev Modified: haiku/trunk/src/apps/sudoku/Sudoku.cpp Log: How come this doesn't generate a warning ? clipped to int32. Modified: haiku/trunk/src/apps/sudoku/Sudoku.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/Sudoku.cpp 2008-02-03 17:52:43 UTC (rev 23846) +++ haiku/trunk/src/apps/sudoku/Sudoku.cpp 2008-02-03 17:53:52 UTC (rev 23847) @@ -92,7 +92,7 @@ int main(int /*argc*/, char** /*argv*/) { - srand(system_time()); + srand(system_time() % INT_MAX); Sudoku sudoku; sudoku.Run(); From mmu_man at mail.berlios.de Sun Feb 3 18:57:58 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 18:57:58 +0100 Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku Message-ID: <200802031757.m13HvwVS023463@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 18:57:55 +0100 (Sun, 03 Feb 2008) New Revision: 23848 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23848&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h haiku/trunk/src/apps/sudoku/SudokuWindow.cpp haiku/trunk/src/apps/sudoku/SudokuWindow.h Log: * Quit on window close. * Added HTML export, and provision for more formats and clipboard export. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 17:53:52 UTC (rev 23847) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 17:57:55 UTC (rev 23848) @@ -190,21 +190,37 @@ status_t -SudokuView::SaveTo(entry_ref& ref, bool asText) +SudokuView::SaveTo(entry_ref& ref, uint32 as) { BFile file; + status_t status = file.SetTo(&ref, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (status < B_OK) return status; - if (asText) { - char line[1024]; - strcpy(line, "# Written by Sudoku\n\n"); - file.Write(line, strlen(line)); + status = SaveTo(file, as); + + return status; +} - uint32 i = 0; +status_t +SudokuView::SaveTo(BDataIO &stream, uint32 as) +{ + BString text; + //BFile *file; + char *line; + uint32 i = 0; + status_t status = EINVAL; + + switch (as) { + case kExportAsText: + text = "# Written by Sudoku\n\n"; + stream.Write(text.String(), text.Length()); + + line = text.LockBuffer(1024); + memset(line, 0, 1024); for (uint32 y = 0; y < fField->Size(); y++) { for (uint32 x = 0; x < fField->Size(); x++) { if (x != 0 && x % fBlockSize == 0) @@ -213,15 +229,77 @@ } line[i++] = '\n'; } + text.UnlockBuffer(); - file.Write(line, i); - } else { + stream.Write(text.String(), text.Length()); + return B_OK; + case kExportAsHTML: + { + text = "\n\n\n" + "\n" + "\n\n\n" + ""; + stream.Write(text.String(), text.Length()); + + //XXX: make border larger on %3 + + text = ""; + BString divider; + divider << (int)(100.0 / fField->Size()) << "%"; + for (uint32 y = 0; y < fField->Size(); y++) { + text << "\n"; + for (uint32 x = 0; x < fField->Size(); x++) { + char buff[2]; + _SetText(buff, fField->ValueAt(x, y)); + if (fField->ValueAt(x, y) == 0) { + text << "\n"; + } + text << "\n"; + } + text << "
\n"; + text << " "; + } else if (fField->FlagsAt(x, y) & kInitialValue) { + text << "\n"; + text << ""; + text << buff; + text << ""; + } else { + text << "\n"; + text << ""; + text << buff; + text << ""; + } + text << "
\n\n"; + + stream.Write(text.String(), text.Length()); + text = "\n"; + stream.Write(text.String(), text.Length()); + return B_OK; } + case kExportAsBitmap: + case kExportAsPicture: + default: + return EINVAL; + } return status; } +status_t +SudokuView::CopyToClipboard() +{ + status_t status = EINVAL; + BMessage data; + return status; +} + + void SudokuView::ClearChanged() { Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 17:53:52 UTC (rev 23847) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 17:57:55 UTC (rev 23848) @@ -19,6 +19,13 @@ }; +enum { + kExportAsText, + kExportAsHTML, + kExportAsBitmap, + kExportAsPicture +}; + class SudokuView : public BView { public: SudokuView(BRect frame, const char* name, const BMessage& settings, @@ -31,7 +38,10 @@ status_t SetTo(const char* data); status_t SetTo(SudokuField* field); - status_t SaveTo(entry_ref& ref, bool asText); + status_t SaveTo(entry_ref& ref, uint32 as=kExportAsText); + status_t SaveTo(BDataIO &to, uint32 as=kExportAsText); + + status_t CopyToClipboard(); void ClearChanged(); void ClearAll(); Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2008-02-03 17:53:52 UTC (rev 23847) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2008-02-03 17:57:55 UTC (rev 23848) @@ -41,7 +41,7 @@ const uint32 kMsgRestoreState = 'rest'; const uint32 kMsgNew = 'new '; const uint32 kMsgStartAgain = 'stag'; -const uint32 kMsgExportAsText = 'extx'; +const uint32 kMsgExportAs = 'expt'; class GenerateSudoku { @@ -134,9 +134,10 @@ SudokuWindow::SudokuWindow() : BWindow(BRect(100, 100, 500, 520), "Sudoku", B_TITLED_WINDOW, - B_ASYNCHRONOUS_CONTROLS), + B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE), fGenerator(NULL), - fStoredState(NULL) + fStoredState(NULL), + fExportFormat(kExportAsText) { BMessage settings; _LoadSettings(settings); @@ -201,8 +202,20 @@ menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("Export As Text" B_UTF8_ELLIPSIS, - new BMessage(kMsgExportAsText))); + subMenu = new BMenu("Export As" B_UTF8_ELLIPSIS); + BMessage *msg; + msg = new BMessage(kMsgExportAs); + msg->AddInt32("as", kExportAsText); + subMenu->AddItem(new BMenuItem("Text", msg)); + msg = new BMessage(kMsgExportAs); + msg->AddInt32("as", kExportAsHTML); + subMenu->AddItem(new BMenuItem("HTML", msg)); + /* + msg = new BMessage(kMsgExportAs); + msg->AddInt32("as", kExportAsBitmap); + subMenu->AddItem(new BMenuItem("Bitmap" B_UTF8_ELLIPSIS, msg)); + */ + menu->AddItem(subMenu); menu->AddSeparatorItem(); @@ -437,10 +450,18 @@ break; } - case kMsgExportAsText: + case kMsgExportAs: + { + if (message->FindInt32("as", (int32 *)&fExportFormat) < B_OK) + fExportFormat = kExportAsText; fSavePanel->Show(); break; + } + case B_COPY: + fSudokuView->CopyToClipboard(); + break; + case B_SAVE_REQUESTED: { entry_ref directoryRef; @@ -454,7 +475,7 @@ entry_ref ref; if (entry.GetRef(&ref) == B_OK) - fSudokuView->SaveTo(ref, true); + fSudokuView->SaveTo(ref, fExportFormat); break; } Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.h 2008-02-03 17:53:52 UTC (rev 23847) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.h 2008-02-03 17:57:55 UTC (rev 23848) @@ -42,6 +42,7 @@ BMenuItem* fUndoItem; BMenuItem* fRedoItem; BMessage* fStoredState; + uint32 fExportFormat; }; #endif // SUDOKU_WINDOW_H From axeld at mail.berlios.de Sun Feb 3 19:04:26 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Feb 2008 19:04:26 +0100 Subject: [Haiku-commits] r23849 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802031804.m13I4QbB030995@sheep.berlios.de> Author: axeld Date: 2008-02-03 19:04:25 +0100 (Sun, 03 Feb 2008) New Revision: 23849 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23849&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: * "call" now sets some useful debugger variables, like _argX for all arguments, and _frame for the stack frame. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-02-03 17:57:55 UTC (rev 23848) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-02-03 18:04:25 UTC (rev 23849) @@ -9,6 +9,7 @@ #include +#include #include #include @@ -376,10 +377,17 @@ kprintf("%#lx", *arg); if (*arg > -0x10000 && *arg < 0x10000) kprintf(" (%ld)", *arg); + + char name[8]; + snprintf(name, sizeof(name), "_arg%ld", i + 1); + set_debug_variable(name, *(uint32 *)arg); + arg++; } kprintf(")\n"); + + set_debug_variable("_frame", nextEbp); } From anevilyak at gmail.com Sun Feb 3 19:09:51 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 3 Feb 2008 12:09:51 -0600 Subject: [Haiku-commits] Haiku-commits Digest, Vol 20, Issue 12 In-Reply-To: References: Message-ID: Do I want to know what needed this error code? :) Rene > Log: > * Added BSD specific errno.h for EDOOFUS (yeah, I know, great error code...) From axeld at pinc-software.de Sun Feb 3 19:20:19 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 03 Feb 2008 19:20:19 +0100 CET Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku In-Reply-To: <200802031757.m13HvwVS023463@sheep.berlios.de> Message-ID: <25910329188-BeMail@zon> mmu_man at BerliOS wrote: > + switch (as) { > + case kExportAsText: Since your messing with my code here, would you please follow our style guide more closely? ;-) The contents of a switch statement are indented one tab further. > +status_t > +SudokuView::CopyToClipboard() > +{ > + status_t status = EINVAL; > + BMessage data; > + return status; > +} That doesn't look right. > + status_t SaveTo(entry_ref& ref, uint32 as=kExportAsText); > + status_t SaveTo(BDataIO &to, uint32 as=kExportAsText); Please add spaces between the variable name, the equal sign, and the default type, thanks! Bye, Axel. From mmu_man at mail.berlios.de Sun Feb 3 19:38:47 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 19:38:47 +0100 Subject: [Haiku-commits] r23850 - haiku/trunk/src/apps/sudoku Message-ID: <200802031838.m13IclXW003749@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 19:38:47 +0100 (Sun, 03 Feb 2008) New Revision: 23850 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23850&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: * Better looking html. * Set mime type when exporting to file. * disable netpositive stuff (only css). * export only the table when not saving to file (clipboard). Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 18:04:25 UTC (rev 23849) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 18:38:47 UTC (rev 23850) @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -209,11 +210,15 @@ SudokuView::SaveTo(BDataIO &stream, uint32 as) { BString text; - //BFile *file; + BFile *file = dynamic_cast(&stream); char *line; uint32 i = 0; status_t status = EINVAL; + BNodeInfo nodeInfo; + if (file) + nodeInfo.SetTo(file); + switch (as) { case kExportAsText: text = "# Written by Sudoku\n\n"; @@ -232,18 +237,28 @@ text.UnlockBuffer(); stream.Write(text.String(), text.Length()); + if (file) + nodeInfo.SetType("text/plain"); return B_OK; case kExportAsHTML: { + bool netPositiveFriendly = false; text = "\n\n\n" "\n" - "\n\n\n" - ""; + "\n\n\n"; + if (file) + stream.Write(text.String(), text.Length()); + + text = ""; stream.Write(text.String(), text.Length()); //XXX: make border larger on %3 @@ -257,18 +272,22 @@ char buff[2]; _SetText(buff, fField->ValueAt(x, y)); if (fField->ValueAt(x, y) == 0) { - text << "\n"; } @@ -278,7 +297,10 @@ stream.Write(text.String(), text.Length()); text = "\n"; - stream.Write(text.String(), text.Length()); + if (file) + stream.Write(text.String(), text.Length()); + if (file) + nodeInfo.SetType("text/html"); return B_OK; } case kExportAsBitmap: From axeld at pinc-software.de Sun Feb 3 20:18:31 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 03 Feb 2008 20:18:31 +0100 CET Subject: [Haiku-commits] r23850 - haiku/trunk/src/apps/sudoku In-Reply-To: <200802031838.m13IclXW003749@sheep.berlios.de> Message-ID: <29402399386-BeMail@zon> mmu_man at BerliOS wrote: > stream.Write(text.String(), text.Length()); > text = "\n"; > - stream.Write(text.String(), text.Length()); > + if (file) > + stream.Write(text.String(), text.Length()); The "if (file)" check doesn't really make any sense there. Bye, Axel. From mmu_man at mail.berlios.de Sun Feb 3 20:35:24 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 20:35:24 +0100 Subject: [Haiku-commits] r23852 - haiku/trunk/src/apps/sudoku Message-ID: <200802031935.m13JZOpU009779@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 20:35:24 +0100 (Sun, 03 Feb 2008) New Revision: 23852 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23852&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: * HTML now looks ok. * Inlcude headers for clipboard too, one might want the css code also. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 19:08:52 UTC (rev 23851) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 19:35:24 UTC (rev 23852) @@ -245,15 +245,35 @@ bool netPositiveFriendly = false; text = "\n\n\n" "\n" "\n\n\n"; - if (file) - stream.Write(text.String(), text.Length()); + /*if (file)*/ + stream.Write(text.String(), text.Length()); text = "Size(); x++) { char buff[2]; _SetText(buff, fField->ValueAt(x, y)); + + char border_right = 's'; + char border_bottom = 's'; + if ((x+1) % fField->BlockSize() == 0) + border_right = 'l'; + if ((y+1) % fField->BlockSize() == 0) + border_bottom = 'l'; + if (x == fField->Size() - 1) + border_right = 'n'; + if (y == fField->Size() - 1) + border_bottom = 'n'; + if (fField->ValueAt(x, y) == 0) { - text << "
\n"; + text << "\n"; text << " "; } else if (fField->FlagsAt(x, y) & kInitialValue) { - text << "\n"; - text << ""; + text << "\n"; + if (netPositiveFriendly) + text << ""; text << buff; - text << ""; + if (netPositiveFriendly) + text << ""; } else { - text << "\n"; - text << ""; + text << "\n"; + if (netPositiveFriendly) + text << ""; text << buff; - text << ""; + if (netPositiveFriendly) + text << ""; } text << "\n"; + text << "\n"; text << " "; } else if (fField->FlagsAt(x, y) & kInitialValue) { - text << "\n"; + text << "\n"; if (netPositiveFriendly) text << ""; text << buff; if (netPositiveFriendly) text << ""; } else { - text << "\n"; + text << "\n"; if (netPositiveFriendly) text << ""; text << buff; @@ -297,9 +332,9 @@ stream.Write(text.String(), text.Length()); text = "\n"; + /*if (file)*/ + stream.Write(text.String(), text.Length()); if (file) - stream.Write(text.String(), text.Length()); - if (file) nodeInfo.SetType("text/html"); return B_OK; } From mmu_man at mail.berlios.de Sun Feb 3 20:42:40 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 20:42:40 +0100 Subject: [Haiku-commits] r23853 - haiku/trunk/src/apps/sudoku Message-ID: <200802031942.m13JgePw010145@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 20:42:40 +0100 (Sun, 03 Feb 2008) New Revision: 23853 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23853&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h Log: Fix Haiku build. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 19:35:24 UTC (rev 23852) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 19:42:40 UTC (rev 23853) @@ -16,9 +16,11 @@ #include #include +#include #include #include #include +#include const uint32 kMsgCheckSolved = 'chks'; Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 19:35:24 UTC (rev 23852) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 19:42:40 UTC (rev 23853) @@ -9,6 +9,7 @@ #include #include +class BDataIO; class SudokuField; struct entry_ref; From stippi at mail.berlios.de Sun Feb 3 20:08:53 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Feb 2008 20:08:53 +0100 Subject: [Haiku-commits] r23851 - haiku/trunk/src/add-ons/disk_systems/intel Message-ID: <200802031908.m13J8rxK006393@sheep.berlios.de> Author: stippi Date: 2008-02-03 20:08:52 +0100 (Sun, 03 Feb 2008) New Revision: 23851 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23851&view=rev Modified: haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp Log: Fix the "Intel Extended Partition" add-on to use the correct disk system name ("Intel Extended Partition"), this allows disks with extended partitions to successfully PrepareForModifications(). I have just used DriveSetup to initialize a partition with BFS. Yay! Modified: haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp 2008-02-03 18:38:47 UTC (rev 23850) +++ haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp 2008-02-03 19:08:52 UTC (rev 23851) @@ -19,7 +19,7 @@ // constructor ExtendedPartitionAddOn::ExtendedPartitionAddOn() - : BDiskSystemAddOn(kPartitionTypeIntel, 0) + : BDiskSystemAddOn(kPartitionTypeIntelExtended, 0) { } From stippi at mail.berlios.de Sun Feb 3 21:24:05 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Feb 2008 21:24:05 +0100 Subject: [Haiku-commits] r23854 - haiku/trunk/src/apps/drivesetup Message-ID: <200802032024.m13KO5Et012915@sheep.berlios.de> Author: stippi Date: 2008-02-03 21:24:05 +0100 (Sun, 03 Feb 2008) New Revision: 23854 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23854&view=rev Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp haiku/trunk/src/apps/drivesetup/DiskView.h haiku/trunk/src/apps/drivesetup/Jamfile haiku/trunk/src/apps/drivesetup/MainWindow.cpp haiku/trunk/src/apps/drivesetup/MainWindow.h haiku/trunk/src/apps/drivesetup/PartitionList.cpp haiku/trunk/src/apps/drivesetup/PartitionList.h haiku/trunk/src/apps/drivesetup/Support.cpp haiku/trunk/src/apps/drivesetup/Support.h Log: * Implemented support for generating global partition_ids for partitionable spaces. This way we can use all the existing logic to select them in either list view or the disk layout view. IAW, selecting empty spaces now works. * Changed the way the Create menu works. It is now only enabled if a space item is selected and then the sub items are filled with the types that the parent partition says it supports for child creation. (Does not yet seem to work.) * PartitionViews for spaces were not put into the partition_id -> view map. * Fixed focus indication when switching the disk for the disk layout view, previously, the correct view was only selected when the disk did not change. * Added a temporary work around to avoid showing bogus space items at all (those smaller than a "cylinder size"). Currently hard coded to 8 MB size. But I already have an idea how we could fix this in the Disk Device API implementation. Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/DiskView.cpp 2008-02-03 20:24:05 UTC (rev 23854) @@ -183,10 +183,11 @@ class DiskView::PartitionLayout : public BDiskDeviceVisitor { public: - PartitionLayout(BView* view) + PartitionLayout(BView* view, SpaceIDMap& spaceIDMap) : fView(view) , fViewMap() , fSelectedPartition(-1) + , fSpaceIDMap(spaceIDMap) { } @@ -258,7 +259,7 @@ } private: - void _AddSpaces(BPartition* partition, PartitionView* parentView) const + void _AddSpaces(BPartition* partition, PartitionView* parentView) { // add any available space on the partition BPartitioningInfo info; @@ -269,10 +270,17 @@ for (int32 i = 0; info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK; i++) { + // TODO: remove again once Disk Device API is fixed + if (!is_valid_partitionable_space(size)) + continue; + // double scale = (double)size / parentSize; + partition_id id + = fSpaceIDMap.SpaceIDFor(partition->ID(), offset); PartitionView* view = new PartitionView("", scale, - offset, parentView->Level() + 1, -2); + offset, parentView->Level() + 1, id); + fViewMap.Put(id, view); BGroupLayout* layout = parentView->GroupLayout(); layout->AddView(_FindInsertIndex(view, layout), view, scale); } @@ -301,18 +309,21 @@ BView* fView; PartitionViewMap fViewMap; partition_id fSelectedPartition; + SpaceIDMap& fSpaceIDMap; }; // #pragma mark - -DiskView::DiskView(const BRect& frame, uint32 resizeMode) +DiskView::DiskView(const BRect& frame, uint32 resizeMode, + SpaceIDMap& spaceIDMap) : Inherited(frame, "diskview", resizeMode, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) , fDiskCount(0) , fDisk(NULL) - , fPartitionLayout(new PartitionLayout(this)) + , fSpaceIDMap(spaceIDMap) + , fPartitionLayout(new PartitionLayout(this, fSpaceIDMap)) { BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset); SetLayout(layout); @@ -407,12 +418,12 @@ void DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition) { - fPartitionLayout->SetSelectedPartition(selectedPartition); - if (fDisk != disk) { fDisk = disk; _UpdateLayout(); } + + fPartitionLayout->SetSelectedPartition(selectedPartition); } Modified: haiku/trunk/src/apps/drivesetup/DiskView.h =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.h 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/DiskView.h 2008-02-03 20:24:05 UTC (rev 23854) @@ -9,12 +9,15 @@ #include #include +#include "Support.h" + class DiskView : public BView { typedef BView Inherited; public: DiskView(const BRect& frame, - uint32 resizeMode); + uint32 resizeMode, + SpaceIDMap& spaceIDMap); virtual ~DiskView(); // BView interface @@ -28,6 +31,7 @@ int32 fDiskCount; BDiskDevice* fDisk; + SpaceIDMap& fSpaceIDMap; class PartitionLayout; PartitionLayout* fPartitionLayout; Modified: haiku/trunk/src/apps/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/apps/drivesetup/Jamfile 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/Jamfile 2008-02-03 20:24:05 UTC (rev 23854) @@ -12,9 +12,8 @@ PartitionList.cpp Support.cpp - : be libcolumnlistview.a - : - DriveSetup.rdef + : be libcolumnlistview.a libshared.a + : DriveSetup.rdef ; if ( $(TARGET_PLATFORM) = libbe_test ) { Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-03 20:24:05 UTC (rev 23854) @@ -35,11 +35,14 @@ class ListPopulatorVisitor : public BDiskDeviceVisitor { public: - ListPopulatorVisitor(PartitionListView* list, int32& diskCount) + ListPopulatorVisitor(PartitionListView* list, int32& diskCount, + SpaceIDMap& spaceIDMap) : fPartitionList(list) , fDiskCount(diskCount) + , fSpaceIDMap(spaceIDMap) { fDiskCount = 0; + fSpaceIDMap.Clear(); // start with an empty list int32 rows = fPartitionList->CountRows(); for (int32 i = rows - 1; i >= 0; i--) { @@ -76,18 +79,25 @@ BPartitioningInfo info; status_t ret = partition->GetPartitioningInfo(&info); if (ret >= B_OK) { + partition_id parentID = partition->ID(); off_t offset; off_t size; for (int32 i = 0; info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK; i++) { - fPartitionList->AddSpace(partition->ID(), offset, size); + // TODO: remove again once Disk Device API is fixed + if (!is_valid_partitionable_space(size)) + continue; + // + partition_id id = fSpaceIDMap.SpaceIDFor(parentID, offset); + fPartitionList->AddSpace(parentID, id, offset, size); } } } PartitionListView* fPartitionList; int32& fDiskCount; + SpaceIDMap& fSpaceIDMap; }; @@ -118,9 +128,7 @@ MSG_MOUNT = 'mnts', MSG_UNMOUNT = 'unmt', MSG_FORMAT = 'frmt', - MSG_CREATE_PRIMARY = 'crpr', - MSG_CREATE_EXTENDED = 'crex', - MSG_CREATE_LOGICAL = 'crlg', + MSG_CREATE = 'crtp', MSG_INITIALIZE = 'init', MSG_DELETE = 'delt', MSG_EJECT = 'ejct', @@ -131,10 +139,14 @@ }; +// #pragma mark - + + MainWindow::MainWindow(BRect frame) : BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) , fCurrentDisk(NULL) + , fSpaceIDMap() { BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu"); @@ -145,13 +157,6 @@ new BMessage(MSG_SURFACE_TEST)); fRescanMI = new BMenuItem("Rescan", new BMessage(MSG_RESCAN)); - fCreatePrimaryMI = new BMenuItem("Primary", - new BMessage(MSG_CREATE_PRIMARY)); - fCreateExtendedMI = new BMenuItem("Extended", - new BMessage(MSG_CREATE_EXTENDED)); - fCreateLogicalMI = new BMenuItem("Logical", - new BMessage(MSG_CREATE_LOGICAL)); - fDeleteMI = new BMenuItem("Delete (not implemented)", new BMessage(MSG_DELETE)); fDeleteMI->SetEnabled(false); @@ -174,10 +179,7 @@ // Parition menu fPartitionMenu = new BMenu("Partition"); - fCreateMenu = new BMenu("Create (not implemented)"); - fCreateMenu->AddItem(fCreatePrimaryMI); - fCreateMenu->AddItem(fCreateExtendedMI); - fCreateMenu->AddItem(fCreateLogicalMI); + fCreateMenu = new BMenu("Create"); fPartitionMenu->AddItem(fCreateMenu); fInitMenu = new BMenu("Initialize"); @@ -202,7 +204,8 @@ BRect r(Bounds()); r.top = menuBar->Frame().bottom + 1; r.bottom = floorf(r.top + r.Height() * 0.33); - fDiskView = new DiskView(r, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); + fDiskView = new DiskView(r, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, + fSpaceIDMap); AddChild(fDiskView); // add PartitionListView @@ -222,7 +225,7 @@ // visit all disks in the system and show their contents _ScanDrives(); - _EnabledDisableMenuItems(NULL, -1); + _EnabledDisableMenuItems(NULL, -1, -1); } @@ -250,15 +253,9 @@ printf("MSG_FORMAT\n"); break; - case MSG_CREATE_PRIMARY: - printf("MSG_CREATE_PRIMARY\n"); + case MSG_CREATE: + printf("MSG_CREATE\n"); break; - case MSG_CREATE_EXTENDED: - printf("MSG_CREATE_EXTENDED\n"); - break; - case MSG_CREATE_LOGICAL: - printf("MSG_CREATE_LOGICAL\n"); - break; case MSG_INITIALIZE: { BString diskSystemName; @@ -366,8 +363,9 @@ void MainWindow::_ScanDrives() { + fSpaceIDMap.Clear(); int32 diskCount = 0; - ListPopulatorVisitor driveVisitor(fListView, diskCount); + ListPopulatorVisitor driveVisitor(fListView, diskCount, fSpaceIDMap); fDDRoster.VisitEachPartition(&driveVisitor); fDiskView->SetDiskCount(diskCount); } @@ -399,8 +397,9 @@ void MainWindow::_AdaptToSelectedPartition() { - partition_id disk = -1; - partition_id partition = -1; + partition_id diskID = -1; + partition_id partitionID = -1; + partition_id parentID = -1; BRow* _selectedRow = fListView->CurrentSelection(); if (_selectedRow) { @@ -409,24 +408,27 @@ BRow* parent = NULL; while (fListView->FindParent(_topLevelRow, &parent, NULL)) _topLevelRow = parent; - + PartitionListRow* topLevelRow = dynamic_cast(_topLevelRow); PartitionListRow* selectedRow = dynamic_cast(_selectedRow); if (topLevelRow) - disk = topLevelRow->ID(); - if (selectedRow) - partition = selectedRow->ID(); + diskID = topLevelRow->ID(); + if (selectedRow) { + partitionID = selectedRow->ID(); + parentID = selectedRow->ParentID(); + } } - _SetToDiskAndPartition(disk, partition); + _SetToDiskAndPartition(diskID, partitionID, parentID); } void -MainWindow::_SetToDiskAndPartition(partition_id disk, partition_id partition) +MainWindow::_SetToDiskAndPartition(partition_id disk, partition_id partition, + partition_id parent) { BDiskDevice* oldDisk = NULL; if (!fCurrentDisk || fCurrentDisk->ID() != disk) { @@ -446,7 +448,7 @@ fCurrentPartitionID = partition; fDiskView->SetDisk(fCurrentDisk, fCurrentPartitionID); - _EnabledDisableMenuItems(fCurrentDisk, fCurrentPartitionID); + _EnabledDisableMenuItems(fCurrentDisk, fCurrentPartitionID, parent); delete oldDisk; } @@ -454,8 +456,12 @@ void MainWindow::_EnabledDisableMenuItems(BDiskDevice* disk, - partition_id selectedPartition) + partition_id selectedPartition, partition_id parentID) { + // clean out Create menu + while (BMenuItem* item = fCreateMenu->RemoveItem(0L)) + delete item; + if (!disk) { fFormatMI->SetEnabled(false); fEjectMI->SetEnabled(false); @@ -469,10 +475,36 @@ // fSurfaceTestMI->SetEnabled(true); fSurfaceTestMI->SetEnabled(false); + // Create menu and items fPartitionMenu->SetEnabled(true); - // fCreateMenu->SetEnabled(/*empty space selected*/); -fCreateMenu->SetEnabled(false); + BPartition* parentPartition = NULL; + if (selectedPartition <= -2) + parentPartition = disk->FindDescendant(parentID); + + if (parentPartition) { + fCreateMenu->SetEnabled(true); + BString supportedChildType; + int32 cookie = 0; + status_t ret; + while ((ret = parentPartition->GetNextSupportedChildType(&cookie, + &supportedChildType)) == B_OK) { + BMessage* message = new BMessage(MSG_CREATE); + message->AddInt32("parent id", parentID); + message->AddInt32("space id", selectedPartition); + message->AddString("type", supportedChildType); + BMenuItem* item = new BMenuItem(supportedChildType.String(), + message); + fCreateMenu->AddItem(item); + } + if (fCreateMenu->CountItems() == 0) + fprintf(stderr, "Failed to get supported child types: %s\n", + strerror(ret)); + } else { + fCreateMenu->SetEnabled(false); + } + + // Mount items BPartition* partition = disk->FindDescendant(selectedPartition); if (partition) { fInitMenu->SetEnabled(!partition->IsMounted()); Modified: haiku/trunk/src/apps/drivesetup/MainWindow.h =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.h 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/MainWindow.h 2008-02-03 20:24:05 UTC (rev 23854) @@ -13,7 +13,9 @@ #include #include +#include "Support.h" + class BDiskDevice; class BPartition; class BMenu; @@ -45,10 +47,12 @@ void _ScanFileSystems(); void _AdaptToSelectedPartition(); - void _SetToDiskAndPartition(partition_id disk, - partition_id partition); + void _SetToDiskAndPartition(partition_id diskID, + partition_id partitionID, + partition_id parentID); void _EnabledDisableMenuItems(BDiskDevice* disk, - partition_id selectedPartition); + partition_id selectedPartition, + partition_id parentID); void _DisplayPartitionError(BString message, const BPartition* partition = NULL, @@ -72,6 +76,8 @@ PartitionListView* fListView; DiskView* fDiskView; + SpaceIDMap fSpaceIDMap; + BMenu* fDiskMenu; BMenu* fPartitionMenu; BMenu* fInitMenu; @@ -82,9 +88,6 @@ BMenuItem* fSurfaceTestMI; BMenuItem* fRescanMI; - BMenuItem* fCreatePrimaryMI; - BMenuItem* fCreateExtendedMI; - BMenuItem* fCreateLogicalMI; BMenuItem* fDeleteMI; BMenuItem* fMountMI; BMenuItem* fUnmountMI; Modified: haiku/trunk/src/apps/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2008-02-03 20:24:05 UTC (rev 23854) @@ -190,10 +190,10 @@ } -PartitionListRow::PartitionListRow(partition_id parentID, off_t offset, - off_t size) +PartitionListRow::PartitionListRow(partition_id parentID, partition_id id, + off_t offset, off_t size) : Inherited() - , fPartitionID(-2) + , fPartitionID(id) , fParentID(parentID) , fOffset(offset) , fSize(size) @@ -288,7 +288,8 @@ PartitionListRow* -PartitionListView::AddSpace(partition_id parentID, off_t offset, off_t size) +PartitionListView::AddSpace(partition_id parentID, partition_id id, + off_t offset, off_t size) { // the parent should already be in the listview PartitionListRow* parent = FindRow(parentID); @@ -297,7 +298,7 @@ // create the row for this partition PartitionListRow* partitionrow = new PartitionListRow(parentID, - offset, size); + id, offset, size); // find a proper insertion index based on the on-disk offset int32 index = _InsertIndexForOffset(parent, offset); Modified: haiku/trunk/src/apps/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/PartitionList.h 2008-02-03 20:24:05 UTC (rev 23854) @@ -64,7 +64,7 @@ public: PartitionListRow(BPartition* partition); PartitionListRow(partition_id parentID, - off_t offset, off_t size); + partition_id id, off_t offset, off_t size); partition_id ID() const { return fPartitionID; } @@ -92,7 +92,7 @@ PartitionListRow* parent = NULL); PartitionListRow* AddPartition(BPartition* partition); PartitionListRow* AddSpace(partition_id parent, - off_t offset, off_t size); + partition_id id, off_t offset, off_t size); private: int32 _InsertIndexForOffset(PartitionListRow* parent, Modified: haiku/trunk/src/apps/drivesetup/Support.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/Support.cpp 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/Support.cpp 2008-02-03 20:24:05 UTC (rev 23854) @@ -10,6 +10,7 @@ #include "Support.h" #include +#include const char* @@ -67,3 +68,43 @@ printf("\tID(): %lx\n\n", partition->ID()); } + +bool +is_valid_partitionable_space(size_t size) +{ + // TODO: remove this again, the DiskDeviceAPI should + // not even show these spaces to begin with + return size >= 8 * 1024 * 1024; +} + + +// #pragma mark -SpaceIDMap + +SpaceIDMap::SpaceIDMap() + : HashMap() + , fNextSpaceID(-2) +{ +} + + +SpaceIDMap::~SpaceIDMap() +{ +} + + +partition_id +SpaceIDMap::SpaceIDFor(partition_id parentID, off_t spaceOffset) +{ + BString key; + key << parentID << ':' << (uint64)spaceOffset; + + if (ContainsKey(key.String())) + return Get(key.String()); + + partition_id newID = fNextSpaceID--; + Put(key.String(), newID); + + return newID; +} + + Modified: haiku/trunk/src/apps/drivesetup/Support.h =================================================================== --- haiku/trunk/src/apps/drivesetup/Support.h 2008-02-03 19:42:40 UTC (rev 23853) +++ haiku/trunk/src/apps/drivesetup/Support.h 2008-02-03 20:24:05 UTC (rev 23854) @@ -6,7 +6,9 @@ #define SUPPORT_H -#include +#include +#include +#include class BPartition; @@ -16,5 +18,20 @@ void dump_partition_info(const BPartition* partition); +bool is_valid_partitionable_space(size_t size); + +class SpaceIDMap : public HashMap { +public: + SpaceIDMap(); + virtual ~SpaceIDMap(); + + partition_id SpaceIDFor(partition_id parentID, + off_t spaceOffset); + +private: + partition_id fNextSpaceID; +}; + + #endif // SUPPORT_H From axeld at pinc-software.de Sun Feb 3 21:32:17 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 03 Feb 2008 21:32:17 +0100 CET Subject: [Haiku-commits] r23854 - haiku/trunk/src/apps/drivesetup In-Reply-To: <200802032024.m13KO5Et012915@sheep.berlios.de> Message-ID: <33828511449-BeMail@zon> stippi at BerliOS wrote: > * Added a temporary work around to avoid showing bogus space items at > all > (those smaller than a "cylinder size"). Currently hard coded to 8 > MB size. > But I already have an idea how we could fix this in the Disk Device > API > implementation. BTW that numbers are part of the device_geometry structure. Nice progress! Bye, Axel. From revol at free.fr Sun Feb 3 22:03:23 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 03 Feb 2008 22:03:23 +0100 CET Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku In-Reply-To: <25910329188-BeMail@zon> Message-ID: <18136293531-BeMail@laptop> > mmu_man at BerliOS wrote: > > + switch (as) { > > + case kExportAsText: > > Since your messing with my code here, would you please follow our > style > guide more closely? ;-) > The contents of a switch statement are indented one tab further. > Gahh, I'm so used to seeing the other one everywhere... Done. > > +status_t > > +SudokuView::CopyToClipboard() > > +{ > > + status_t status = EINVAL; > > + BMessage data; > > + return status; > > +} > > That doesn't look right. WIP. > > > + status_t SaveTo(entry_ref& ref, uint32 as=kExportAsText); > > + status_t SaveTo(BDataIO &to, uint32 as=kExportAsText); > > Please add spaces between the variable name, the equal sign, and the > default type, thanks! Done. Fran?ois. From revol at free.fr Sun Feb 3 22:07:38 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 03 Feb 2008 22:07:38 +0100 CET Subject: [Haiku-commits] r23850 - haiku/trunk/src/apps/sudoku In-Reply-To: <29402399386-BeMail@zon> Message-ID: <18391131387-BeMail@laptop> > mmu_man at BerliOS wrote: > > stream.Write(text.String(), text.Length()); > > text = "\n"; > > - stream.Write(text.String(), text.Length()); > > + if (file) > > + stream.Write(text.String(), text.Length()); > > The "if (file)" check doesn't really make any sense there. > That was because I wanted to only copy the tag of the html to the clipboard. An app wanting the html would likely only want to paste part of html code into existing code, so without the headers. But it needs css anyway so it's probably simpler to paste all and remove unwanted. I don't know any app that can paste html yet though anyway :D Maybe Pe would like to on html files... (I should check my XEmacs port and add that for html buffers :p) Fran?ois. From mmu_man at mail.berlios.de Sun Feb 3 22:37:24 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 3 Feb 2008 22:37:24 +0100 Subject: [Haiku-commits] r23855 - haiku/trunk/src/apps/sudoku Message-ID: <200802032137.m13LbObT018429@sheep.berlios.de> Author: mmu_man Date: 2008-02-03 22:37:23 +0100 (Sun, 03 Feb 2008) New Revision: 23855 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23855&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h haiku/trunk/src/apps/sudoku/SudokuWindow.cpp Log: * Reindent & style fix. * Added copy-to-clipboard. * Added picture and bitmap clipboard formats. Now you can just paste into either a text or graphics app. Even Gobe uses the text in word processor and bitmap in picture editor :) Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 20:24:05 UTC (rev 23854) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 21:37:23 UTC (rev 23855) @@ -16,10 +16,13 @@ #include #include +#include +#include #include #include #include #include +#include #include @@ -222,129 +225,155 @@ nodeInfo.SetTo(file); switch (as) { - case kExportAsText: - text = "# Written by Sudoku\n\n"; - stream.Write(text.String(), text.Length()); + case kExportAsText: + text = "# Written by Sudoku\n\n"; + stream.Write(text.String(), text.Length()); - line = text.LockBuffer(1024); - memset(line, 0, 1024); - for (uint32 y = 0; y < fField->Size(); y++) { - for (uint32 x = 0; x < fField->Size(); x++) { - if (x != 0 && x % fBlockSize == 0) - line[i++] = ' '; - _SetText(&line[i++], fField->ValueAt(x, y)); + line = text.LockBuffer(1024); + memset(line, 0, 1024); + for (uint32 y = 0; y < fField->Size(); y++) { + for (uint32 x = 0; x < fField->Size(); x++) { + if (x != 0 && x % fBlockSize == 0) + line[i++] = ' '; + _SetText(&line[i++], fField->ValueAt(x, y)); + } + line[i++] = '\n'; } - line[i++] = '\n'; - } - text.UnlockBuffer(); + text.UnlockBuffer(); - stream.Write(text.String(), text.Length()); - if (file) - nodeInfo.SetType("text/plain"); - return B_OK; - case kExportAsHTML: - { - bool netPositiveFriendly = false; - text = "\n\n\n" - "\n" - "\n\n\n"; - /*if (file)*/ - stream.Write(text.String(), text.Length()); + "td.sudoku_nn { border-right: " BS_N "; border-bottom: " BS_N "; }\n" + "td.sudoku_sn { border-right: " BS_S "; border-bottom: " BS_N "; }\n" + "td.sudoku_ns { border-right: " BS_N "; border-bottom: " BS_S "; }\n" + "td.sudoku_ss { border-right: " BS_S "; border-bottom: " BS_S "; }\n" + "td.sudoku_nl { border-right: " BS_N "; border-bottom: " BS_L "; }\n" + "td.sudoku_sl { border-right: " BS_S "; border-bottom: " BS_L "; }\n" + "td.sudoku_ln { border-right: " BS_L "; border-bottom: " BS_N "; }\n" + "td.sudoku_ls { border-right: " BS_L "; border-bottom: " BS_S "; }\n" + "td.sudoku_ll { border-right: " BS_L "; border-bottom: " BS_L "; }\n" + "\n" + "\n\n\n"; + stream.Write(text.String(), text.Length()); - text = ""; - stream.Write(text.String(), text.Length()); + text << " class=\"sudoku\">"; + stream.Write(text.String(), text.Length()); - //XXX: make border larger on %3 - - text = ""; - BString divider; - divider << (int)(100.0 / fField->Size()) << "%"; - for (uint32 y = 0; y < fField->Size(); y++) { - text << "\n"; - for (uint32 x = 0; x < fField->Size(); x++) { - char buff[2]; - _SetText(buff, fField->ValueAt(x, y)); - - char border_right = 's'; - char border_bottom = 's'; - if ((x+1) % fField->BlockSize() == 0) - border_right = 'l'; - if ((y+1) % fField->BlockSize() == 0) - border_bottom = 'l'; - if (x == fField->Size() - 1) - border_right = 'n'; - if (y == fField->Size() - 1) - border_bottom = 'n'; - - if (fField->ValueAt(x, y) == 0) { - text << "\n"; + for (uint32 x = 0; x < fField->Size(); x++) { + char buff[2]; + _SetText(buff, fField->ValueAt(x, y)); + + char border_right = 's'; + char border_bottom = 's'; + if ((x+1) % fField->BlockSize() == 0) + border_right = 'l'; + if ((y+1) % fField->BlockSize() == 0) + border_bottom = 'l'; + if (x == fField->Size() - 1) + border_right = 'n'; + if (y == fField->Size() - 1) + border_bottom = 'n'; + + if (fField->ValueAt(x, y) == 0) { + text << "\n"; } - text << "\n"; + text << "\n"; } - text << "\n"; + text << "
\n"; - text << " "; - } else if (fField->FlagsAt(x, y) & kInitialValue) { - text << "\n"; - if (netPositiveFriendly) - text << ""; - text << buff; - if (netPositiveFriendly) - text << ""; - } else { - text << "\n"; - if (netPositiveFriendly) - text << ""; - text << buff; - if (netPositiveFriendly) - text << ""; + text = ""; + BString divider; + divider << (int)(100.0 / fField->Size()) << "%"; + for (uint32 y = 0; y < fField->Size(); y++) { + text << "
\n"; + text << " "; + } else if (fField->FlagsAt(x, y) & kInitialValue) { + text << "\n"; + if (netPositiveFriendly) + text << ""; + text << buff; + if (netPositiveFriendly) + text << ""; + } else { + text << "\n"; + if (netPositiveFriendly) + text << ""; + text << buff; + if (netPositiveFriendly) + text << ""; + } + text << "
\n\n"; + + stream.Write(text.String(), text.Length()); + text = "\n"; + stream.Write(text.String(), text.Length()); + if (file) + nodeInfo.SetType("text/html"); + return B_OK; } - text << "
\n\n"; - - stream.Write(text.String(), text.Length()); - text = "\n"; - /*if (file)*/ - stream.Write(text.String(), text.Length()); - if (file) - nodeInfo.SetType("text/html"); - return B_OK; + case kExportAsBitmap: + { + BMallocIO mio; + status = SaveTo(mio, kExportAsPicture); + if (status < B_OK) + return status; + mio.Seek(0LL, SEEK_SET); + BPicture picture; + status = picture.Unflatten(&mio); + if (status < B_OK) + return status; + BBitmap *bitmap = new BBitmap(Bounds(), B_BITMAP_ACCEPTS_VIEWS, B_RGB32); + BView *view = new BView(Bounds(), "bitmap", B_FOLLOW_NONE, B_WILL_DRAW); + bitmap->AddChild(view); + if (bitmap->Lock()) { + view->DrawPicture(&picture); + view->Sync(); + view->RemoveSelf(); + delete view; + bitmap->Unlock(); + } + BMessage msg(B_OK); + status = bitmap->Archive(&msg); + if (status >= B_OK) { + status = msg.Flatten(&stream); + } + delete bitmap; + return status; + } + case kExportAsPicture: + { + BPicture picture; + BeginPicture(&picture); + Draw(Bounds()); + if (EndPicture()) { + status = picture.Flatten(&stream); + } + return status; + } + default: + return EINVAL; } - case kExportAsBitmap: - case kExportAsPicture: - default: - return EINVAL; - } return status; } @@ -354,7 +383,49 @@ SudokuView::CopyToClipboard() { status_t status = EINVAL; - BMessage data; + BMessage *clip; + if (be_clipboard->Lock()) { + BMallocIO mio; + be_clipboard->Clear(); + clip = be_clipboard->Data(); + if (clip) { + // first as bitmap as we need to archive to the message + if (SaveTo(mio, kExportAsBitmap) >= B_OK) { + mio.Seek(0LL, SEEK_SET); + // ShowImage wants this... nasty + clip->Unflatten(&mio); + // ArtPaint uses that + clip->AddData("image/bitmap", B_MESSAGE_TYPE, mio.Buffer(), mio.BufferLength()); + // Becasso uses that ? + clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mio.Buffer(), mio.BufferLength()); + // Gobe Productive uses that... + // QuickRes as well, with a rect field. + clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE, mio.Buffer(), mio.BufferLength()); + } + mio.Seek(0LL, SEEK_SET); + mio.SetSize(0LL); + + if (SaveTo(mio, kExportAsHTML) >= B_OK) + clip->AddData("text/html", B_MIME_TYPE, mio.Buffer(), mio.BufferLength()); + mio.Seek(0LL, SEEK_SET); + mio.SetSize(0LL); + + if (SaveTo(mio, kExportAsText) >= B_OK) + clip->AddData("text/plain", B_MIME_TYPE, mio.Buffer(), mio.BufferLength()); + mio.Seek(0LL, SEEK_SET); + mio.SetSize(0LL); + + // flattened BPicture, anyone handles that ? + if (SaveTo(mio, kExportAsPicture) >= B_OK) { + clip->AddData("text/x-vnd.Be-picture", B_MIME_TYPE, mio.Buffer(), mio.BufferLength()); + + } + mio.SetSize(0LL); + + be_clipboard->Commit(); + } + be_clipboard->Unlock(); + } return status; } Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 20:24:05 UTC (rev 23854) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 21:37:23 UTC (rev 23855) @@ -39,8 +39,8 @@ status_t SetTo(const char* data); status_t SetTo(SudokuField* field); - status_t SaveTo(entry_ref& ref, uint32 as=kExportAsText); - status_t SaveTo(BDataIO &to, uint32 as=kExportAsText); + status_t SaveTo(entry_ref& ref, uint32 as = kExportAsText); + status_t SaveTo(BDataIO &to, uint32 as = kExportAsText); status_t CopyToClipboard(); Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2008-02-03 20:24:05 UTC (rev 23854) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2008-02-03 21:37:23 UTC (rev 23855) @@ -217,6 +217,9 @@ */ menu->AddItem(subMenu); + menu->AddItem(item = new BMenuItem("Copy", + new BMessage(B_COPY), 'C')); + menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("About Sudoku" B_UTF8_ELLIPSIS, From mmu_man at mail.berlios.de Mon Feb 4 00:00:57 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 4 Feb 2008 00:00:57 +0100 Subject: [Haiku-commits] r23856 - haiku/trunk/src/apps/sudoku Message-ID: <200802032300.m13N0vSJ025344@sheep.berlios.de> Author: mmu_man Date: 2008-02-04 00:00:56 +0100 (Mon, 04 Feb 2008) New Revision: 23856 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23856&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h Log: It's now replicable. The dragger doesn't move correctly on resize though. And it needs a better menu. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 21:37:23 UTC (rev 23855) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 23:00:56 UTC (rev 23856) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -30,22 +31,84 @@ const uint32 kStrongLineSize = 2; +extern const char* kSignature; + SudokuView::SudokuView(BRect frame, const char* name, const BMessage& settings, uint32 resizingMode) : BView(frame, name, resizingMode, - B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), - fField(NULL), - fShowHintX(~0UL), - fLastHintValue(~0UL), - fLastField(~0UL), - fKeyboardX(0), - fKeyboardY(0), - fShowKeyboardFocus(false), - fEditable(true) + B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS) { + InitObject(&settings); + + BRect rect(Bounds()); + rect.top = rect.bottom - 7; + rect.left = rect.right - 7; + BDragger *dw = new BDragger(rect, this); + AddChild(dw); +} + + +SudokuView::SudokuView(BMessage* archive) + : BView(archive) +{ + InitObject(archive); +} + + +SudokuView::~SudokuView() +{ + delete fField; +} + + +status_t +SudokuView::Archive(BMessage* into, bool deep = true) const +{ + status_t status; + + status = BView::Archive(into, deep); + if (status < B_OK) + return status; + + status = into->AddString("add_on", kSignature); + if (status < B_OK) + return status; + + status = into->AddRect("bounds", Bounds()); + if (status < B_OK) + return status; + + status = SaveState(*into); + if (status < B_OK) + return status; + return B_OK; +} + + +BArchivable* +SudokuView::Instantiate(BMessage* archive) +{ + if (!validate_instantiation(archive, "SudokuView")) + return NULL; + return new SudokuView(archive); +} + + +void +SudokuView::InitObject(const BMessage* archive) +{ + fField = NULL; + fShowHintX = ~0UL; + fLastHintValue = ~0UL; + fLastField = ~0UL; + fKeyboardX = 0; + fKeyboardY = 0; + fShowKeyboardFocus = false; + fEditable = true; + BMessage field; - if (settings.FindMessage("field", &field) == B_OK) { + if (archive->FindMessage("field", &field) == B_OK) { fField = new SudokuField(&field); if (fField->InitCheck() != B_OK) { delete fField; @@ -58,9 +121,9 @@ fBlockSize = fField->BlockSize(); - if (settings.FindInt32("hint flags", (int32*)&fHintFlags) != B_OK) + if (archive->FindInt32("hint flags", (int32*)&fHintFlags) != B_OK) fHintFlags = kMarkInvalid; - if (settings.FindBool("show cursor", &fShowCursor) != B_OK) + if (archive->FindBool("show cursor", &fShowCursor) != B_OK) fShowCursor = false; SetViewColor(B_TRANSPARENT_COLOR); @@ -72,14 +135,8 @@ } -SudokuView::~SudokuView() -{ - delete fField; -} - - status_t -SudokuView::SaveState(BMessage& state) +SudokuView::SaveState(BMessage& state) const { BMessage field; status_t status = fField->Archive(&field, true); Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 21:37:23 UTC (rev 23855) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2008-02-03 23:00:56 UTC (rev 23856) @@ -31,10 +31,15 @@ public: SudokuView(BRect frame, const char* name, const BMessage& settings, uint32 resizingMode); + SudokuView(BMessage* archive); virtual ~SudokuView(); - status_t SaveState(BMessage& state); + virtual status_t Archive(BMessage* into, bool deep = true) const; + static BArchivable* Instantiate(BMessage* archive); + void InitObject(const BMessage* archive); + status_t SaveState(BMessage& state) const; + status_t SetTo(entry_ref& ref); status_t SetTo(const char* data); status_t SetTo(SudokuField* field); From axeld at pinc-software.de Mon Feb 4 00:31:55 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 04 Feb 2008 00:31:55 +0100 CET Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku In-Reply-To: <18136293531-BeMail@laptop> Message-ID: <44606074756-BeMail@zon> "Fran?ois Revol" wrote: > Gahh, I'm so used to seeing the other one everywhere... You really should do more Haiku programming... ;-)) > Done. Thanks! Mmhh... Sudoku replicant :-) Bye, Axel. From axeld at pinc-software.de Mon Feb 4 00:33:19 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 04 Feb 2008 00:33:19 +0100 CET Subject: [Haiku-commits] Haiku-commits Digest, Vol 20, Issue 12 In-Reply-To: Message-ID: <44690361627-BeMail@zon> "Rene Gollent" wrote: > > Log: > > * Added BSD specific errno.h for EDOOFUS (yeah, I know, great error > > code...) > Do I want to know what needed this error code? :) I can't tell. But I can tell you that it was BSD's libutil :-) Bye, Axel. From revol at free.fr Mon Feb 4 00:50:25 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 04 Feb 2008 00:50:25 +0100 CET Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku In-Reply-To: <44606074756-BeMail@zon> Message-ID: <4008589364-BeMail@laptop> > "Fran?ois Revol" wrote: > > Gahh, I'm so used to seeing the other one everywhere... > > You really should do more Haiku programming... ;-)) Suppose so :D > Thanks! Mmhh... Sudoku replicant :-) Yeah, nasty dragger though... Btw, your handling of KeyDown is ... at least azerty-unfriendly. Fran?ois. From mmu_man at mail.berlios.de Mon Feb 4 01:39:35 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 4 Feb 2008 01:39:35 +0100 Subject: [Haiku-commits] r23857 - haiku/trunk/src/apps/sudoku Message-ID: <200802040039.m140dZSd018156@sheep.berlios.de> Author: mmu_man Date: 2008-02-04 01:39:34 +0100 (Mon, 04 Feb 2008) New Revision: 23857 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23857&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: Move the dragger back to its corner on resize. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-03 23:00:56 UTC (rev 23856) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-04 00:39:34 UTC (rev 23857) @@ -581,6 +581,11 @@ fHintFont.GetHeight(&fontHeight); fHintBaseline = ceilf(fontHeight.ascent) / 2 + (fHintHeight - ceilf(fontHeight.descent)) / 2; + + // fix the dragger's position + BView *dragger = FindView("_dragger_"); + if (dragger) + dragger->MoveTo(Bounds().right - 7, Bounds().bottom - 7); } From mmu_man at mail.berlios.de Mon Feb 4 02:25:49 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 4 Feb 2008 02:25:49 +0100 Subject: [Haiku-commits] r23858 - haiku/trunk/src/apps/sudoku Message-ID: <200802040125.m141Pn1b025022@sheep.berlios.de> Author: mmu_man Date: 2008-02-04 02:25:48 +0100 (Mon, 04 Feb 2008) New Revision: 23858 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23858&view=rev Modified: haiku/trunk/src/apps/sudoku/Sudoku.cpp haiku/trunk/src/apps/sudoku/Sudoku.h haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: Move the about box to a static so the replicant can use it as well. Modified: haiku/trunk/src/apps/sudoku/Sudoku.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/Sudoku.cpp 2008-02-04 00:39:34 UTC (rev 23857) +++ haiku/trunk/src/apps/sudoku/Sudoku.cpp 2008-02-04 01:25:48 UTC (rev 23858) @@ -4,6 +4,8 @@ */ +#include "Sudoku.h" + #include "SudokuWindow.h" #include @@ -13,23 +15,6 @@ #include -class Sudoku : public BApplication { -public: - Sudoku(); - virtual ~Sudoku(); - - virtual void ReadyToRun(); - - virtual void RefsReceived(BMessage *message); - virtual void MessageReceived(BMessage *message); - - virtual void AboutRequested(); - -private: - SudokuWindow* fWindow; -}; - - const char* kSignature = "application/x-vnd.Haiku-Sudoku"; @@ -69,6 +54,13 @@ void Sudoku::AboutRequested() { + Sudoku::DisplayAbout(); +} + + +void +Sudoku::DisplayAbout() +{ BAlert *alert = new BAlert("about", "Sudoku\n" "\twritten by Axel D?rfler\n" "\tCopyright 2007, Haiku Inc.\n", "Ok"); Modified: haiku/trunk/src/apps/sudoku/Sudoku.h =================================================================== --- haiku/trunk/src/apps/sudoku/Sudoku.h 2008-02-04 00:39:34 UTC (rev 23857) +++ haiku/trunk/src/apps/sudoku/Sudoku.h 2008-02-04 01:25:48 UTC (rev 23858) @@ -5,6 +5,28 @@ #ifndef SUDOKU_H #define SUDOKU_H +#include + +class BMessage; +class SudokuWindow; + +class Sudoku : public BApplication { +public: + Sudoku(); + virtual ~Sudoku(); + + virtual void ReadyToRun(); + + virtual void RefsReceived(BMessage *message); + virtual void MessageReceived(BMessage *message); + + virtual void AboutRequested(); + static void DisplayAbout(); + +private: + SudokuWindow* fWindow; +}; + extern const char* kSignature; #endif // SUDOKU_H Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-04 00:39:34 UTC (rev 23857) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-04 01:25:48 UTC (rev 23858) @@ -6,6 +6,7 @@ #include "SudokuView.h" +#include "Sudoku.h" #include "SudokuField.h" #include "SudokuSolver.h" @@ -1022,6 +1023,10 @@ break; } + case B_ABOUT_REQUESTED: + Sudoku::DisplayAbout(); + break; + default: BView::MessageReceived(message); break; From mmu_man at mail.berlios.de Mon Feb 4 04:31:18 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 4 Feb 2008 04:31:18 +0100 Subject: [Haiku-commits] r23859 - haiku/trunk/src/apps/sudoku Message-ID: <200802040331.m143VI0B009277@sheep.berlios.de> Author: mmu_man Date: 2008-02-04 04:31:17 +0100 (Mon, 04 Feb 2008) New Revision: 23859 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23859&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: Fix gcc4 build. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-04 01:25:48 UTC (rev 23858) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-02-04 03:31:17 UTC (rev 23859) @@ -64,7 +64,7 @@ status_t -SudokuView::Archive(BMessage* into, bool deep = true) const +SudokuView::Archive(BMessage* into, bool deep) const { status_t status; From axeld at pinc-software.de Mon Feb 4 09:35:59 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 04 Feb 2008 09:35:59 +0100 CET Subject: [Haiku-commits] r23848 - haiku/trunk/src/apps/sudoku In-Reply-To: <4008589364-BeMail@laptop> Message-ID: <1037230498-BeMail@zon> "Fran?ois Revol" wrote: > Btw, your handling of KeyDown is ... at least azerty-unfriendly. Yes, I noticed other problems with that, too (like when trying to solve a 4x4 sudoku; but beware, the sudoku algorithms are actually too dumb to be of any use in that size...). Bye, Axel. From jackburton at mail.berlios.de Mon Feb 4 10:43:18 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 4 Feb 2008 10:43:18 +0100 Subject: [Haiku-commits] r23860 - haiku/trunk/src/apps/terminal Message-ID: <200802040943.m149hI5r003096@sheep.berlios.de> Author: jackburton Date: 2008-02-04 10:43:16 +0100 (Mon, 04 Feb 2008) New Revision: 23860 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23860&view=rev Modified: haiku/trunk/src/apps/terminal/PrefWindow.cpp haiku/trunk/src/apps/terminal/PrefWindow.h haiku/trunk/src/apps/terminal/Shell.cpp haiku/trunk/src/apps/terminal/SmartTabView.cpp haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp haiku/trunk/src/apps/terminal/TermWindow.h Log: Opening the preferences window and hitting "cancel" would shrink the window every time, without reason, since _Revert() was called even if no changes were made. Build the list of window sizes dynamically, this way we get rid of some code duplication. Removed implementation of TermWindow::QuitRequested(). The B_QUIT_ON_WINDOW close takes care of quitting the application. Some cleanups. Modified: haiku/trunk/src/apps/terminal/PrefWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/PrefWindow.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/PrefWindow.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -26,7 +26,7 @@ : BWindow(_CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE), - fPrefTemp(new PrefHandler(PrefHandler::Default())), + fPreviousPref(new PrefHandler(PrefHandler::Default())), fSavePanel(NULL), fDirty(false), fPrefDlgMessenger(messenger) @@ -37,8 +37,8 @@ BRect rect = top->Bounds(); rect.bottom *= .75; - AppearancePrefView *prefView= new AppearancePrefView(rect, "Appearance", - fPrefDlgMessenger); + AppearancePrefView *prefView + = new AppearancePrefView(rect, "Appearance", fPrefDlgMessenger); top->AddChild(prefView); fSaveAsFileButton = new BButton(BRect(0, 0, 1, 1), "savebutton", "Save to File" B_UTF8_ELLIPSIS, @@ -80,7 +80,7 @@ PrefWindow::Quit() { fPrefDlgMessenger.SendMessage(MSG_PREF_CLOSED); - delete fPrefTemp; + delete fPreviousPref; delete fSavePanel; BWindow::Quit(); } @@ -140,8 +140,8 @@ void PrefWindow::_Save() { - delete fPrefTemp; - fPrefTemp = new PrefHandler(PrefHandler::Default()); + delete fPreviousPref; + fPreviousPref = new PrefHandler(PrefHandler::Default()); BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) { @@ -154,13 +154,15 @@ void PrefWindow::_Revert() { - PrefHandler::SetDefault(new PrefHandler(fPrefTemp)); + if (fDirty) { + PrefHandler::SetDefault(new PrefHandler(fPreviousPref)); - fPrefDlgMessenger.SendMessage(MSG_HALF_FONT_CHANGED); - fPrefDlgMessenger.SendMessage(MSG_COLOR_CHANGED); - fPrefDlgMessenger.SendMessage(MSG_INPUT_METHOD_CHANGED); + fPrefDlgMessenger.SendMessage(MSG_HALF_FONT_CHANGED); + fPrefDlgMessenger.SendMessage(MSG_COLOR_CHANGED); + fPrefDlgMessenger.SendMessage(MSG_INPUT_METHOD_CHANGED); - fDirty = false; + fDirty = false; + } } Modified: haiku/trunk/src/apps/terminal/PrefWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/PrefWindow.h 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/PrefWindow.h 2008-02-04 09:43:16 UTC (rev 23860) @@ -46,7 +46,7 @@ BRect _CenteredRect(BRect rect); private: - PrefHandler *fPrefTemp; + PrefHandler *fPreviousPref; BFilePanel *fSavePanel; BButton *fSaveAsFileButton, Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -144,6 +144,7 @@ Shell::Close() { delete fTermParse; + fTermParse = NULL; if (fFd >= 0) { close(fFd); Modified: haiku/trunk/src/apps/terminal/SmartTabView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/SmartTabView.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/SmartTabView.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -106,7 +106,8 @@ BTabView::Select(index); BView *view = ViewForTab(index); if (view != NULL) { - view->ResizeTo(ContainerView()->Bounds().Width(), ContainerView()->Bounds().Height()); + view->ResizeTo(ContainerView()->Bounds().Width(), + ContainerView()->Bounds().Height()); } } @@ -121,8 +122,7 @@ else if (index < CountTabs()) Select(index + 1); } - BTab *tab = RemoveTab(index); - delete tab; + delete RemoveTab(index); } @@ -132,11 +132,20 @@ if (target == NULL) return; + BTabView::AddTab(target, tab); + if (CountTabs() == 1) { + // Call select on the tab, since + // we're resizing the contained view + // inside that function + Select(0); + } else if (CountTabs() == 2) { + // Need to resize the view, since we're + // switching from "normal" to tabbed mode ContainerView()->ResizeBy(0, -TabHeight()); ContainerView()->MoveBy(0, TabHeight()); + Window()->ResizeBy(0, TabHeight()); } - BTabView::AddTab(target, tab); Invalidate(TabFrame(CountTabs() - 1).InsetByCopy(-2, -2)); } @@ -145,12 +154,13 @@ BTab * SmartTabView::RemoveTab(int32 index) { - BTab *tab = BTabView::RemoveTab(index); - if (CountTabs() == 1) { + if (CountTabs() == 2) { + // see above + Window()->ResizeBy(0, -TabHeight()); ContainerView()->MoveBy(0, -TabHeight()); ContainerView()->ResizeBy(0, TabHeight()); } - return tab; + return BTabView::RemoveTab(index); } @@ -175,5 +185,3 @@ return -1; } - - Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -342,7 +342,7 @@ } parsestate = groundtable; now_coding = fView->Encoding(); - } + } switch (parsestate[c]) { case CASE_PRINT: Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -1081,19 +1081,17 @@ TermView::_DrawLines(int x1, int y1, ushort attr, uchar *buf, int width, int mouse, int cursor, BView *inView) { - int x2, y2; - int forecolor, backcolor; - rgb_color rgb_fore = fTextForeColor, rgb_back = fTextBackColor, rgb_tmp; + rgb_color rgb_fore = fTextForeColor, rgb_back = fTextBackColor; inView->SetFont(&fHalfFont); // Set pen point - x2 = x1 + fFontWidth * width; - y2 = y1 + fFontHeight; + int x2 = x1 + fFontWidth * width; + int y2 = y1 + fFontHeight; // color attribute - forecolor = IS_FORECOLOR(attr); - backcolor = IS_BACKCOLOR(attr); + int forecolor = IS_FORECOLOR(attr); + int backcolor = IS_BACKCOLOR(attr); if (IS_FORESET(attr)) rgb_fore = kTermColorTable[forecolor]; @@ -1105,13 +1103,13 @@ if (cursor) { rgb_fore = fCursorForeColor; rgb_back = fCursorBackColor; - } else if (mouse){ + } else if (mouse) { rgb_fore = fSelectForeColor; rgb_back = fSelectBackColor; } else { // Reverse attribute(If selected area, don't reverse color). if (IS_INVERSE(attr)) { - rgb_tmp = rgb_fore; + rgb_color rgb_tmp = rgb_fore; rgb_fore = rgb_back; rgb_back = rgb_tmp; } @@ -1131,7 +1129,7 @@ // bold attribute. if (IS_BOLD(attr)) { inView->MovePenTo(x1 + 1, y1 + fFontAscent); - + inView->SetDrawingMode(B_OP_OVER); inView->DrawString((char *)buf); inView->SetDrawingMode(B_OP_COPY); @@ -1154,7 +1152,7 @@ return; float viewheight = fTermRows * fFontHeight; - float start_pos = fTop -(fScrBufSize - fTermRows *2) * fFontHeight; + float start_pos = fTop -(fScrBufSize - fTermRows * 2) * fFontHeight; if (start_pos > 0) { fScrollBar->SetRange(start_pos, viewheight + fTop - fFontHeight); @@ -1263,7 +1261,6 @@ void TermView::AttachedToWindow() { - SetFont(&fHalfFont); MakeFocus(true); if (fScrollBar) fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 09:43:16 UTC (rev 23860) @@ -40,7 +40,6 @@ #include -const static float kViewOffset = 3; const static int32 kMaxTabs = 6; // messages constants @@ -131,7 +130,7 @@ { PrefHandler menuText; - LoadLocaleFile (&menuText); + LoadLocaleFile(&menuText); // Menu bar object. fMenubar = new BMenuBar(Bounds(), "mbar"); @@ -172,13 +171,8 @@ // Make Help Menu. fHelpmenu = new BMenu("Settings"); fWindowSizeMenu = new BMenu("Window Size"); - fWindowSizeMenu->AddItem(new BMenuItem("80x24", new BMessage(EIGHTYTWENTYFOUR))); - fWindowSizeMenu->AddItem(new BMenuItem("80x25", new BMessage(EIGHTYTWENTYFIVE))); - fWindowSizeMenu->AddItem(new BMenuItem("80x40", new BMessage(EIGHTYFORTY))); - fWindowSizeMenu->AddItem(new BMenuItem("132x24", new BMessage(ONETHREETWOTWENTYFOUR))); - fWindowSizeMenu->AddItem(new BMenuItem("132x25", new BMessage(ONETHREETWOTWENTYFIVE))); - fWindowSizeMenu->AddItem(new BMenuItem("Fullscreen", new BMessage(FULLSCREEN), B_ENTER)); - + _BuildWindowSizeMenu(fWindowSizeMenu); + fEncodingmenu = new BMenu("Font Encoding"); fEncodingmenu->SetRadioMode(true); MakeEncodingMenu(fEncodingmenu, true); @@ -249,6 +243,7 @@ be_roster->Launch(TERM_SIGNATURE); break; } + case MENU_PREF_OPEN: if (!fPrefWindow) fPrefWindow = new PrefWindow(this); @@ -336,15 +331,17 @@ _ActiveTermView()->SetEncoding(encodingId); break; - // Message from Preference panel. - case MSG_ROWS_CHANGED: case MSG_COLS_CHANGED: { - BRect rect = _ActiveTermView()->SetTermSize(PrefHandler::Default()->getInt32 (PREF_ROWS), - PrefHandler::Default()->getInt32 (PREF_COLS), 0); + int32 columns, rows; + message->FindInt32("columns", &columns); + message->FindInt32("rows", &rows); + PrefHandler::Default()->setInt32(PREF_COLS, columns); + PrefHandler::Default()->setInt32(PREF_ROWS, rows); + + _ActiveTermView()->SetTermSize(rows, columns, 0); - ResizeTo (rect.Width()+ B_V_SCROLL_BAR_WIDTH + kViewOffset * 2, - rect.Height()+fMenubar->Bounds().Height() + kViewOffset *2); + _ResizeView(_ActiveTermView()); BPath path; if (PrefHandler::GetDefaultPath(path) == B_OK) @@ -364,36 +361,7 @@ break; } - case EIGHTYTWENTYFOUR: - PrefHandler::Default()->setString(PREF_COLS, "80"); - PrefHandler::Default()->setString(PREF_ROWS, "24"); - PostMessage(MSG_COLS_CHANGED); - break; - - case EIGHTYTWENTYFIVE: - PrefHandler::Default()->setString(PREF_COLS, "80"); - PrefHandler::Default()->setString(PREF_ROWS, "25"); - PostMessage(MSG_COLS_CHANGED); - break; - - case EIGHTYFORTY: - PrefHandler::Default()->setString(PREF_COLS, "80"); - PrefHandler::Default()->setString(PREF_ROWS, "40"); - PostMessage(MSG_COLS_CHANGED); - break; - case ONETHREETWOTWENTYFOUR: - PrefHandler::Default()->setString(PREF_COLS, "132"); - PrefHandler::Default()->setString(PREF_ROWS, "24"); - PostMessage(MSG_COLS_CHANGED); - break; - - case ONETHREETWOTWENTYFIVE: - PrefHandler::Default()->setString(PREF_COLS, "132"); - PrefHandler::Default()->setString(PREF_ROWS, "25"); - PostMessage(MSG_COLS_CHANGED); - break; - case FULLSCREEN: if (!fSavedFrame.IsValid()) { // go fullscreen float mbHeight = fMenubar->Bounds().Height() + 1; @@ -480,8 +448,8 @@ size -= 1; // limit the font size - if (size < 8) - size = 8; + if (size < 6) + size = 6; else if (size > 20) size = 20; @@ -506,14 +474,6 @@ } -bool -TermWindow::QuitRequested() -{ - be_app->PostMessage(B_QUIT_REQUESTED); - return BWindow::QuitRequested(); -} - - void TermWindow::_SetTermColors(TermView *termView) { @@ -648,10 +608,6 @@ // Resize Window ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, viewHeight + fMenubar->Bounds().Height()); - - // TODO: If I don't do this, the view won't show up. - // Bug in BTabView or in my code ? - fTabView->Select(0); } } catch (...) { // most probably out of memory. That's bad. @@ -703,6 +659,27 @@ void +TermWindow::_CheckChildren() +{ + // There seems to be no separate list of sessions, so we have to iterate + // through the tabs. + int32 count = fTabView->CountTabs(); + for (int32 i = count - 1; i >= 0; i--) { + // get the term view + BScrollView* scrollView + = dynamic_cast(fTabView->ViewForTab(i)); + if (!scrollView) + continue; + TermView* termView = dynamic_cast(scrollView->Target()); + if (!termView) + continue; + + termView->CheckShellGone(); + } +} + + +void TermWindow::_ResizeView(TermView *view) { int fontWidth, fontHeight; @@ -720,8 +697,8 @@ float width, height; view->GetPreferredSize(&width, &height); - width += B_V_SCROLL_BAR_WIDTH + kViewOffset * 2; - height += fMenubar->Bounds().Height() + kViewOffset * 2; + width += B_V_SCROLL_BAR_WIDTH; + height += fMenubar->Bounds().Height(); ResizeTo(width, height); view->Invalidate(); @@ -729,27 +706,33 @@ void -TermWindow::_CheckChildren() +TermWindow::_BuildWindowSizeMenu(BMenu *menu) { - // There seems to be no separate list of sessions, so we have to iterate - // through the tabs. - int32 count = fTabView->CountTabs(); - for (int32 i = count - 1; i >= 0; i--) { - // get the term view - BScrollView* scrollView - = dynamic_cast(fTabView->ViewForTab(i)); - if (!scrollView) - continue; - TermView* termView = dynamic_cast(scrollView->Target()); - if (!termView) - continue; - - termView->CheckShellGone(); + const int32 windowSizes[5][2] = { + { 80, 24 }, + { 80, 25 }, + { 80, 40 }, + { 132, 24 }, + { 132, 25 } + }; + + const int32 sizeNum = sizeof(windowSizes) / sizeof(windowSizes[0]); + for (int32 i = 0; i < sizeNum; i++) { + char label[32]; + int32 columns = windowSizes[i][0]; + int32 rows = windowSizes[i][1]; + snprintf(label, sizeof(label), "%ldx%ld", columns, rows); + BMessage *message = new BMessage(MSG_COLS_CHANGED); + message->AddInt32("columns", columns); + message->AddInt32("rows", rows); + menu->AddItem(new BMenuItem(label, message)); } + + menu->AddItem(new BMenuItem("Fullscreen", + new BMessage(FULLSCREEN), B_ENTER)); } - // CustomTermView CustomTermView::CustomTermView(int32 rows, int32 columns, int32 argc, const char **argv, int32 historySize) : Modified: haiku/trunk/src/apps/terminal/TermWindow.h =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.h 2008-02-04 03:31:17 UTC (rev 23859) +++ haiku/trunk/src/apps/terminal/TermWindow.h 2008-02-04 09:43:16 UTC (rev 23860) @@ -54,9 +54,7 @@ virtual void MessageReceived(BMessage *message); virtual void WindowActivated(bool); virtual void MenusBeginning(); - virtual bool QuitRequested(); - private: void _SetTermColors(TermView *termView); void _InitWindow(); @@ -70,6 +68,7 @@ int32 _IndexOfTermView(TermView* termView) const; void _CheckChildren(); void _ResizeView(TermView *view); + void _BuildWindowSizeMenu(BMenu *menu); SmartTabView *fTabView; TermView *fTermView; From jackburton at mail.berlios.de Mon Feb 4 11:46:25 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 4 Feb 2008 11:46:25 +0100 Subject: [Haiku-commits] r23861 - haiku/trunk/src/apps/terminal Message-ID: <200802041046.m14AkPib009914@sheep.berlios.de> Author: jackburton Date: 2008-02-04 11:46:24 +0100 (Mon, 04 Feb 2008) New Revision: 23861 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23861&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp Log: The termview was resized 2 pixels less than needed. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-04 09:43:16 UTC (rev 23860) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-04 10:46:24 UTC (rev 23861) @@ -314,9 +314,9 @@ TermView::GetPreferredSize(float *width, float *height) { if (width) - *width = fTermColumns * fFontWidth - 1; + *width = fTermColumns * fFontWidth; if (height) - *height = fTermRows * fFontHeight - 1; + *height = fTermRows * fFontHeight; } @@ -353,7 +353,7 @@ fScrTop = 0; fScrBot = fTermRows - 1; - BRect rect(0, 0, fTermColumns * fFontWidth - 1, fTermRows * fFontHeight - 1); + BRect rect(0, 0, fTermColumns * fFontWidth, fTermRows * fFontHeight); if (resize) ResizeTo(rect.Width(), rect.Height()); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 09:43:16 UTC (rev 23860) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 10:46:24 UTC (rev 23861) @@ -698,7 +698,8 @@ float width, height; view->GetPreferredSize(&width, &height); width += B_V_SCROLL_BAR_WIDTH; - height += fMenubar->Bounds().Height(); + height += fMenubar->Bounds().Height() + 2; + ResizeTo(width, height); view->Invalidate(); From jackburton at mail.berlios.de Mon Feb 4 12:08:08 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 4 Feb 2008 12:08:08 +0100 Subject: [Haiku-commits] r23862 - haiku/trunk/src/apps/terminal Message-ID: <200802041108.m14B88Ft012398@sheep.berlios.de> Author: jackburton Date: 2008-02-04 12:08:06 +0100 (Mon, 04 Feb 2008) New Revision: 23862 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23862&view=rev Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp haiku/trunk/src/apps/terminal/TermWindow.cpp Log: And of course, actually save the font size selected via shortcut. Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-02-04 10:46:24 UTC (rev 23861) +++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-02-04 11:08:06 UTC (rev 23862) @@ -49,7 +49,7 @@ r.OffsetBy(r.Width() + 10, 0); menu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, - atoi(PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE))); + PrefHandler::Default()->getInt32(PREF_HALF_FONT_SIZE)); fFontSize = new BMenuField(r, "size", "Size:", menu, B_WILL_DRAW); fFontSize->SetDivider(sizeDividerSize); AddChild(fFontSize); Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 10:46:24 UTC (rev 23861) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-02-04 11:08:06 UTC (rev 23862) @@ -455,6 +455,7 @@ font.SetSize(size); view->SetTermFont(&font); + PrefHandler::Default()->setInt32(PREF_HALF_FONT_SIZE, size); _ResizeView(view); break; From axeld at mail.berlios.de Mon Feb 4 16:01:35 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Feb 2008 16:01:35 +0100 Subject: [Haiku-commits] r23863 - in haiku/trunk: headers/os/game headers/os/interface src/kits/interface Message-ID: <200802041501.m14F1ZVt024848@sheep.berlios.de> Author: axeld Date: 2008-02-04 16:01:34 +0100 (Mon, 04 Feb 2008) New Revision: 23863 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23863&view=rev Modified: haiku/trunk/headers/os/game/DirectWindow.h haiku/trunk/headers/os/interface/Window.h haiku/trunk/src/kits/interface/Window.cpp Log: * Ingo broke binary compatibility of Window.h in r18649, thanks to Stefano for finding this. This should fix bug #1734. * Removed unused BWindow members and the temporary PrintToStream() method. * Indentation cleanup (DirectWindow.h had some spaces instead of tabs). Modified: haiku/trunk/headers/os/game/DirectWindow.h =================================================================== --- haiku/trunk/headers/os/game/DirectWindow.h 2008-02-04 11:08:06 UTC (rev 23862) +++ haiku/trunk/headers/os/game/DirectWindow.h 2008-02-04 15:01:34 UTC (rev 23863) @@ -1,9 +1,9 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: - * Stefano Ceccherini + * Stefano Ceccherini */ #ifndef _DIRECT_WINDOW_H #define _DIRECT_WINDOW_H @@ -55,24 +55,26 @@ class BDirectWindow : public BWindow { public: BDirectWindow(BRect frame, const char *title, window_type type, - uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE); - BDirectWindow(BRect frame, const char *title, window_look look, - window_feel feel, uint32 flags, - uint32 workspace = B_CURRENT_WORKSPACE); + uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE); + BDirectWindow(BRect frame, const char *title, window_look look, + window_feel feel, uint32 flags, + uint32 workspace = B_CURRENT_WORKSPACE); virtual ~BDirectWindow(); - - static BArchivable* Instantiate(BMessage *data); + + static BArchivable* Instantiate(BMessage *data); virtual status_t Archive(BMessage *data, bool deep = true) const; - virtual void Quit(); + virtual void Quit(); virtual void DispatchMessage(BMessage *message, BHandler *handler); virtual void MessageReceived(BMessage *message); virtual void FrameMoved(BPoint newPosition); - virtual void WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces); + virtual void WorkspacesChanged(uint32 oldWorkspaces, + uint32 newWorkspaces); virtual void WorkspaceActivated(int32 workspaceIndex, bool state); virtual void FrameResized(float newWidth, float newHeight); virtual void Minimize(bool minimize); - virtual void Zoom(BPoint recPosition, float recWidth, float recHeight); + virtual void Zoom(BPoint recPosition, float recWidth, + float recHeight); virtual void ScreenChanged(BRect screenFrame, color_space depth); virtual void MenusBeginning(); virtual void MenusEnded(); @@ -89,30 +91,28 @@ virtual void task_looper(); virtual BMessage* ConvertToMessage(void *raw, int32 code); + public: + virtual void DirectConnected(direct_buffer_info *info); + status_t GetClippingRegion(BRegion *region, + BPoint *origin = NULL) const; + status_t SetFullScreen(bool enable); + bool IsFullScreen() const; - public: - virtual void DirectConnected(direct_buffer_info *info); - status_t GetClippingRegion(BRegion *region, BPoint *origin = NULL) const; - status_t SetFullScreen(bool enable); - bool IsFullScreen() const; - static bool SupportsWindowMode(screen_id id = B_MAIN_SCREEN_ID); - private: - typedef BWindow inherited; - virtual void _ReservedDirectWindow1(); - virtual void _ReservedDirectWindow2(); - virtual void _ReservedDirectWindow3(); - virtual void _ReservedDirectWindow4(); - + virtual void _ReservedDirectWindow1(); + virtual void _ReservedDirectWindow2(); + virtual void _ReservedDirectWindow3(); + virtual void _ReservedDirectWindow4(); + BDirectWindow(); - BDirectWindow(BDirectWindow &); - BDirectWindow &operator=(BDirectWindow &); + BDirectWindow(BDirectWindow& other); + BDirectWindow& operator=(BDirectWindow& other); - static int32 _daemon_thread(void *arg); + static int32 _daemon_thread(void* arg); int32 _DirectDaemon(); bool _LockDirect() const; void _UnlockDirect() const; @@ -125,27 +125,27 @@ bool fIsFullScreen; bool _unused; bool fInDirectConnect; - + int32 fDirectLock; sem_id fDirectSem; uint32 fDirectLockCount; thread_id fDirectLockOwner; - char *fDirectLockStack; - + char* fDirectLockStack; + sem_id fDisableSem; sem_id fDisableSemAck; - + uint32 fInitStatus; uint32 fInfoAreaSize; - + uint32 _reserved[2]; - + area_id fClonedClippingArea; area_id fSourceClippingArea; thread_id fDirectDaemonId; - direct_buffer_info *fBufferDesc; - + direct_buffer_info* fBufferDesc; + uint32 _more_reserved_[17]; }; -#endif +#endif // _DIRECT_WINDOW_H Modified: haiku/trunk/headers/os/interface/Window.h =================================================================== --- haiku/trunk/headers/os/interface/Window.h 2008-02-04 11:08:06 UTC (rev 23862) +++ haiku/trunk/headers/os/interface/Window.h 2008-02-04 15:01:34 UTC (rev 23863) @@ -92,177 +92,165 @@ class BWindow : public BLooper { public: - BWindow(BRect frame, const char* title, - window_type type, uint32 flags, - uint32 workspace = B_CURRENT_WORKSPACE); - BWindow(BRect frame, const char* title, - window_look look, window_feel feel, - uint32 flags, - uint32 workspace = B_CURRENT_WORKSPACE); - virtual ~BWindow(); + BWindow(BRect frame, const char* title, + window_type type, uint32 flags, + uint32 workspace = B_CURRENT_WORKSPACE); + BWindow(BRect frame, const char* title, + window_look look, window_feel feel, uint32 flags, + uint32 workspace = B_CURRENT_WORKSPACE); + virtual ~BWindow(); - BWindow(BMessage* data); + BWindow(BMessage* data); + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; - static BArchivable* Instantiate(BMessage* data); - virtual status_t Archive(BMessage* data, bool deep = true) const; + virtual void Quit(); + void Close() { Quit(); } - virtual void Quit(); - void Close() { Quit(); } + void AddChild(BView* child, BView* before = NULL); + bool RemoveChild(BView* child); + int32 CountChildren() const; + BView* ChildAt(int32 index) const; - void AddChild(BView* child, BView* before = NULL); - bool RemoveChild(BView* child); - int32 CountChildren() const; - BView* ChildAt(int32 index) const; + virtual void DispatchMessage(BMessage* message, + BHandler* handler); + virtual void MessageReceived(BMessage* message); + virtual void FrameMoved(BPoint newPosition); + virtual void WorkspacesChanged(uint32 oldWorkspaces, + uint32 newWorkspaces); + virtual void WorkspaceActivated(int32 workspace, bool state); + virtual void FrameResized(float newWidth, float newHeight); + virtual void Minimize(bool minimize); + virtual void Zoom(BPoint origin, float width, float height); + void Zoom(); + void SetZoomLimits(float maxWidth, float maxHeight); + virtual void ScreenChanged(BRect screenSize, color_space format); - virtual void DispatchMessage(BMessage* message, - BHandler* handler); - virtual void MessageReceived(BMessage* message); - virtual void FrameMoved(BPoint new_position); - virtual void WorkspacesChanged(uint32 oldWorkspaces, - uint32 newWorkspaces); - virtual void WorkspaceActivated(int32 workspace, - bool state); - virtual void FrameResized(float newWidth, float newHeight); - virtual void Minimize(bool minimize); - virtual void Zoom(BPoint origin, float width, float height); - void Zoom(); - void SetZoomLimits(float maxWidth, float maxHeight); - virtual void ScreenChanged(BRect screenSize, - color_space format); + void SetPulseRate(bigtime_t rate); + bigtime_t PulseRate() const; - void SetPulseRate(bigtime_t rate); - bigtime_t PulseRate() const; + void AddShortcut(uint32 key, uint32 modifiers, + BMessage* message); + void AddShortcut(uint32 key, uint32 modifiers, + BMessage* message, BHandler* target); + void RemoveShortcut(uint32 key, uint32 modifiers); - void AddShortcut(uint32 key, uint32 modifiers, - BMessage *message); - void AddShortcut(uint32 key, uint32 modifiers, - BMessage *message, - BHandler *target); - void RemoveShortcut(uint32 key, uint32 modifiers); + void SetDefaultButton(BButton* button); + BButton* DefaultButton() const; - void SetDefaultButton(BButton* button); - BButton* DefaultButton() const; + virtual void MenusBeginning(); + virtual void MenusEnded(); - virtual void MenusBeginning(); - virtual void MenusEnded(); + bool NeedsUpdate() const; + void UpdateIfNeeded(); - bool NeedsUpdate() const; - void UpdateIfNeeded(); + BView* FindView(const char* viewName) const; + BView* FindView(BPoint) const; + BView* CurrentFocus() const; - BView* FindView(const char* viewName) const; - BView* FindView(BPoint) const; - BView* CurrentFocus() const; + void Activate(bool = true); + virtual void WindowActivated(bool state); - void Activate(bool = true); - virtual void WindowActivated(bool state); + void ConvertToScreen(BPoint* point) const; + BPoint ConvertToScreen(BPoint point) const; + void ConvertFromScreen(BPoint* point) const; + BPoint ConvertFromScreen(BPoint point) const; + void ConvertToScreen(BRect* rect) const; + BRect ConvertToScreen(BRect rect) const; + void ConvertFromScreen(BRect* rect) const; + BRect ConvertFromScreen(BRect rect) const; - void ConvertToScreen(BPoint* point) const; - BPoint ConvertToScreen(BPoint point) const; - void ConvertFromScreen(BPoint* point) const; - BPoint ConvertFromScreen(BPoint point) const; - void ConvertToScreen(BRect* rect) const; - BRect ConvertToScreen(BRect rect) const; - void ConvertFromScreen(BRect* rect) const; - BRect ConvertFromScreen(BRect rect) const; + void MoveBy(float dx, float dy); + void MoveTo(BPoint); + void MoveTo(float x, float y); + void ResizeBy(float dx, float dy); + void ResizeTo(float width, float height); - void MoveBy(float dx, float dy); - void MoveTo(BPoint); - void MoveTo(float x, float y); - void ResizeBy(float dx, float dy); - void ResizeTo(float width, float height); + virtual void Show(); + virtual void Hide(); + bool IsHidden() const; + bool IsMinimized() const; - virtual void Show(); - virtual void Hide(); - bool IsHidden() const; - bool IsMinimized() const; + void Flush() const; + void Sync() const; - void Flush() const; - void Sync() const; + status_t SendBehind(const BWindow* window); - status_t SendBehind(const BWindow* window); + void DisableUpdates(); + void EnableUpdates(); - void DisableUpdates(); - void EnableUpdates(); - - void BeginViewTransaction(); + void BeginViewTransaction(); // referred as OpenViewTransaction() in BeBook - void EndViewTransaction(); + void EndViewTransaction(); // referred as CommitViewTransaction() in BeBook - BRect Bounds() const; - BRect Frame() const; - const char* Title() const; - void SetTitle(const char* title); - bool IsFront() const; - bool IsActive() const; + BRect Bounds() const; + BRect Frame() const; + const char* Title() const; + void SetTitle(const char* title); + bool IsFront() const; + bool IsActive() const; - void SetKeyMenuBar(BMenuBar* bar); - BMenuBar* KeyMenuBar() const; + void SetKeyMenuBar(BMenuBar* bar); + BMenuBar* KeyMenuBar() const; - void SetSizeLimits(float minWidth, float maxWidth, - float minHeight, float maxHeight); - void GetSizeLimits(float* minWidth, float* maxWidth, - float* minHeight, float* maxHeight); + void SetSizeLimits(float minWidth, float maxWidth, + float minHeight, float maxHeight); + void GetSizeLimits(float* minWidth, float* maxWidth, + float* minHeight, float* maxHeight); - status_t SetDecoratorSettings(const BMessage& settings); - status_t GetDecoratorSettings(BMessage* settings) const; + status_t SetDecoratorSettings(const BMessage& settings); + status_t GetDecoratorSettings(BMessage* settings) const; - uint32 Workspaces() const; - void SetWorkspaces(uint32); + uint32 Workspaces() const; + void SetWorkspaces(uint32); - BView* LastMouseMovedView() const; + BView* LastMouseMovedView() const; - virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, - const char* property); - virtual status_t GetSupportedSuites(BMessage* data); + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 form, + const char* property); + virtual status_t GetSupportedSuites(BMessage* data); - status_t AddToSubset(BWindow* window); - status_t RemoveFromSubset(BWindow* window); + status_t AddToSubset(BWindow* window); + status_t RemoveFromSubset(BWindow* window); - virtual status_t Perform(perform_code d, void* arg); + virtual status_t Perform(perform_code d, void* arg); - status_t SetType(window_type type); - window_type Type() const; + status_t SetType(window_type type); + window_type Type() const; - status_t SetLook(window_look look); - window_look Look() const; + status_t SetLook(window_look look); + window_look Look() const; - status_t SetFeel(window_feel feel); - window_feel Feel() const; + status_t SetFeel(window_feel feel); + window_feel Feel() const; - status_t SetFlags(uint32); - uint32 Flags() const; + status_t SetFlags(uint32); + uint32 Flags() const; - bool IsModal() const; - bool IsFloating() const; + bool IsModal() const; + bool IsFloating() const; - status_t SetWindowAlignment(window_alignment mode, - int32 h, - int32 hOffset = 0, - int32 width = 0, - int32 widthOffset = 0, - int32 v = 0, - int32 vOffset = 0, - int32 height = 0, - int32 heightOffset = 0); - status_t GetWindowAlignment(window_alignment* mode = NULL, - int32* h = NULL, - int32* hOffset = NULL, - int32* width = NULL, - int32* widthOffset = NULL, - int32* v = NULL, - int32* vOffset = NULL, - int32* height = NULL, - int32* heightOffset = NULL) const; + status_t SetWindowAlignment(window_alignment mode, int32 h, + int32 hOffset = 0, int32 width = 0, + int32 widthOffset = 0, int32 v = 0, + int32 vOffset = 0, int32 height = 0, + int32 heightOffset = 0); + status_t GetWindowAlignment(window_alignment* mode = NULL, + int32* h = NULL, int32* hOffset = NULL, + int32* width = NULL, int32* widthOffset = NULL, + int32* v = NULL, int32* vOffset = NULL, + int32* height = NULL, + int32* heightOffset = NULL) const; - virtual bool QuitRequested(); - virtual thread_id Run(); + virtual bool QuitRequested(); + virtual thread_id Run(); - virtual void SetLayout(BLayout* layout); - BLayout* GetLayout() const; + virtual void SetLayout(BLayout* layout); + BLayout* GetLayout() const; - void InvalidateLayout(bool descendants = false); + void InvalidateLayout(bool descendants = false); private: typedef BLooper inherited; @@ -282,116 +270,107 @@ friend void _set_menu_sem_(BWindow* w, sem_id sem); friend status_t _safe_get_server_token_(const BLooper*, int32*); - virtual void _ReservedWindow1(); - virtual void _ReservedWindow2(); - virtual void _ReservedWindow3(); - virtual void _ReservedWindow4(); - virtual void _ReservedWindow5(); - virtual void _ReservedWindow6(); - virtual void _ReservedWindow7(); - virtual void _ReservedWindow8(); + virtual void _ReservedWindow2(); + virtual void _ReservedWindow3(); + virtual void _ReservedWindow4(); + virtual void _ReservedWindow5(); + virtual void _ReservedWindow6(); + virtual void _ReservedWindow7(); + virtual void _ReservedWindow8(); - BWindow(); - BWindow(BWindow&); - BWindow& operator=(BWindow&); + BWindow(); + BWindow(BWindow&); + BWindow& operator=(BWindow&); - BWindow(BRect frame, int32 bitmapToken); - void _InitData(BRect frame, const char* title, - window_look look, window_feel feel, - uint32 flags, uint32 workspace, - int32 bitmapToken = -1); + BWindow(BRect frame, int32 bitmapToken); + void _InitData(BRect frame, const char* title, + window_look look, window_feel feel, + uint32 flags, uint32 workspace, + int32 bitmapToken = -1); - void BitmapClose(); // to be implemented - virtual void task_looper(); + virtual void task_looper(); - virtual BMessage* ConvertToMessage(void* raw, int32 code); + virtual BMessage* ConvertToMessage(void* raw, int32 code); - void AddShortcut(uint32 key, uint32 modifiers, - BMenuItem* item); - BHandler* _DetermineTarget(BMessage* message, - BHandler* target); - bool _UnpackMessage(unpack_cookie& state, - BMessage** _message, - BHandler** _target, - bool* _usePreferred); - void _SanitizeMessage(BMessage* message, - BHandler* target, - bool usePreferred); - bool _StealMouseMessage(BMessage* message, - bool& deleteMessage); + void AddShortcut(uint32 key, uint32 modifiers, + BMenuItem* item); + BHandler* _DetermineTarget(BMessage* message, + BHandler* target); + bool _UnpackMessage(unpack_cookie& state, + BMessage** _message, BHandler** _target, + bool* _usePreferred); + void _SanitizeMessage(BMessage* message, + BHandler* target, bool usePreferred); + bool _StealMouseMessage(BMessage* message, + bool& deleteMessage); - bool InUpdate(); - void _DequeueAll(); - window_type _ComposeType(window_look look, - window_feel feel) const; - void _DecomposeType(window_type type, - window_look* look, - window_feel* feel) const; + bool InUpdate(); + void _DequeueAll(); + window_type _ComposeType(window_look look, + window_feel feel) const; + void _DecomposeType(window_type type, window_look* look, + window_feel* feel) const; - void SetIsFilePanel(bool yes); - bool IsFilePanel() const; + void SetIsFilePanel(bool yes); + bool IsFilePanel() const; - void _CreateTopView(); - void _AdoptResize(); - void _SetFocus(BView* focusView, - bool notifyIputServer = false); - void _SetName(const char* title); + void _CreateTopView(); + void _AdoptResize(); + void _SetFocus(BView* focusView, + bool notifyIputServer = false); + void _SetName(const char* title); - Shortcut* _FindShortcut(uint32 key, uint32 modifiers); - BView* _FindView(BView* view, BPoint point) const; - BView* _FindView(int32 token); - BView* _LastViewChild(BView* parent); + Shortcut* _FindShortcut(uint32 key, uint32 modifiers); + BView* _FindView(BView* view, BPoint point) const; + BView* _FindView(int32 token); + BView* _LastViewChild(BView* parent); - BView* _FindNextNavigable(BView *focus, uint32 flags); - BView* _FindPreviousNavigable(BView *focus, - uint32 flags); - bool _HandleKeyDown(BMessage* event); - void _KeyboardNavigation(); + BView* _FindNextNavigable(BView *focus, uint32 flags); + BView* _FindPreviousNavigable(BView *focus, uint32 flags); + bool _HandleKeyDown(BMessage* event); + void _KeyboardNavigation(); - // Debug (TODO: to be removed) - void PrintToStream() const; - private: - char* fTitle; - int32 server_token; // not yet used - bool fInTransaction; - bool fActive; - short fShowLevel; - uint32 fFlags; + char* fTitle; + int32 _unused0; + bool fInTransaction; + bool fActive; + short fShowLevel; + uint32 fFlags; - BView* fTopView; - BView* fFocus; - BView* fLastMouseMovedView; - uint32 _unused1; - BMenuBar* fKeyMenuBar; - BButton* fDefaultButton; - BList fShortcuts; - int32 fTopViewToken; - bool _unused2; // was fPulseEnabled - bool fViewsNeedPulse; // not yet used - bool fIsFilePanel; - bool fMaskActivated; - bigtime_t fPulseRate; - bool fWaitingForMenu; - bool fMinimized; - bool fNoQuitShortcut; - bool _unused3; - sem_id fMenuSem; - float fMaxZoomHeight; - float fMaxZoomWidth; - float fMinHeight; - float fMinWidth; - float fMaxHeight; - float fMaxWidth; - BRect fFrame; - window_look fLook; - window_feel fFeel; - int32 fLastViewToken; + BView* fTopView; + BView* fFocus; + BView* fLastMouseMovedView; + uint32 _unused1; + BMenuBar* fKeyMenuBar; + BButton* fDefaultButton; + BList fShortcuts; + int32 fTopViewToken; + bool _unused2; + bool _unused3; + bool fIsFilePanel; + bool _unused4; + bigtime_t fPulseRate; + bool _unused5; + bool fMinimized; + bool fNoQuitShortcut; + bool _unused6; + sem_id fMenuSem; + float fMaxZoomHeight; + float fMaxZoomWidth; + float fMinHeight; + float fMinWidth; + float fMaxHeight; + float fMaxWidth; + BRect fFrame; + window_look fLook; + window_feel fFeel; + int32 fLastViewToken; BPrivate::PortLink* fLink; - BMessageRunner* fPulseRunner; - BRect fPreviousFrame; + BMessageRunner* fPulseRunner; + BRect fPreviousFrame; - uint32 _reserved[9]; + uint32 _reserved[9]; }; #endif // _WINDOW_H Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-02-04 11:08:06 UTC (rev 23862) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-02-04 15:01:34 UTC (rev 23863) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -9,6 +9,12 @@ */ +#include + +#include +#include +#include + #include #include #include @@ -20,13 +26,12 @@ #include #include #include -#include -#include #include -#include #include +#include #include +#include #include #include #include @@ -36,11 +41,7 @@ #include #include -#include -#include -#include - //#define DEBUG_WIN #ifdef DEBUG_WIN # define STRACE(x) printf x @@ -69,7 +70,8 @@ class BWindow::Shortcut { public: Shortcut(uint32 key, uint32 modifiers, BMenuItem* item); - Shortcut(uint32 key, uint32 modifiers, BMessage* message, BHandler* target); + Shortcut(uint32 key, uint32 modifiers, BMessage* message, + BHandler* target); ~Shortcut(); bool Matches(uint32 key, uint32 modifiers) const; @@ -2480,15 +2482,8 @@ fPulseRate = 500000; fPulseRunner = NULL; - // TODO: see if you can use 'fViewsNeedPulse' - fIsFilePanel = false; - // TODO: see WHEN is this used! - fMaskActivated = false; - - // TODO: see WHEN is this used! - fWaitingForMenu = false; fMenuSem = -1; fMinimized = false; @@ -3213,11 +3208,7 @@ modifiers = 0; // handle BMenuBar key - if (key == B_ESCAPE && (modifiers & B_COMMAND_KEY) != 0 - && fKeyMenuBar) { - // TODO: ask Marc about 'fWaitingForMenu' member! - - // fWaitingForMenu = true; + if (key == B_ESCAPE && (modifiers & B_COMMAND_KEY) != 0 && fKeyMenuBar) { fKeyMenuBar->StartMenuBar(0, true, false, NULL); return true; } @@ -3513,10 +3504,16 @@ } -//------------------------------------------------------------------------------ -// Virtual reserved Functions +// #pragma mark - C++ binary compatibility kludge -void BWindow::_ReservedWindow1() {} + +extern "C" void +_ReservedWindow1__7BWindow() +{ + // SetLayout() +} + + void BWindow::_ReservedWindow2() {} void BWindow::_ReservedWindow3() {} void BWindow::_ReservedWindow4() {} @@ -3525,89 +3522,3 @@ void BWindow::_ReservedWindow7() {} void BWindow::_ReservedWindow8() {} -void -BWindow::PrintToStream() const -{ - printf("BWindow '%s' data:\ - Title = %s\ - Token = %ld\ - InTransaction = %s\ - Active = %s\ - fShowLevel = %d\ - Flags = %lx\ - send_port = %ld\ - receive_port = %ld\ - fTopView name = %s\ - focus view name = %s\ - lastMouseMoved = %s\ - fLink = %p\ - KeyMenuBar name = %s\ - DefaultButton = %s\ - # of shortcuts = %ld", - Name(), fTitle, - _get_object_token_(this), - fInTransaction == true ? "yes" : "no", - fActive == true ? "yes" : "no", - fShowLevel, - fFlags, - fLink->SenderPort(), - fLink->ReceiverPort(), - fTopView != NULL ? fTopView->Name() : "NULL", - fFocus != NULL ? fFocus->Name() : "NULL", - fLastMouseMovedView != NULL ? fLastMouseMovedView->Name() : "NULL", - fLink, - fKeyMenuBar != NULL ? fKeyMenuBar->Name() : "NULL", - fDefaultButton != NULL ? fDefaultButton->Name() : "NULL", - fShortcuts.CountItems()); -/* - for( int32 i=0; ikey > 127)?"ASCII":"UNICODE"); - key->message->PrintToStream(); - } -*/ - printf("\ - topViewToken = %ld\ - isFilePanel = %s\ - MaskActivated = %s\ - pulseRate = %lld\ - waitingForMenu = %s\ - minimized = %s\ - Menu semaphore = %ld\ - maxZoomHeight = %f\ - maxZoomWidth = %f\ - minWindHeight = %f\ - minWindWidth = %f\ - maxWindHeight = %f\ - maxWindWidth = %f\ - frame = ( %f, %f, %f, %f )\ - look = %d\ - feel = %d\ - lastViewToken = %ld\ - pulseRunner = %s\n", - fTopViewToken, - fIsFilePanel==true?"Yes":"No", - fMaskActivated==true?"Yes":"No", - fPulseRate, - fWaitingForMenu==true?"Yes":"No", - fMinimized==true?"Yes":"No", - fMenuSem, - fMaxZoomHeight, - fMaxZoomWidth, - fMinHeight, - fMinWidth, - fMaxHeight, - fMaxWidth, - fFrame.left, fFrame.top, fFrame.right, fFrame.bottom, - (int16)fLook, - (int16)fFeel, - fLastViewToken, - fPulseRunner != NULL ? "In place" : "NULL"); -} - -/* -TODO list: - *) test arguments for SetWindowAligment - *) call hook functions: MenusBeginning, MenusEnded. Add menu activation code. -*/ - From bonefish at mail.berlios.de Mon Feb 4 18:54:41 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 4 Feb 2008 18:54:41 +0100 Subject: [Haiku-commits] r23864 - in haiku/trunk: headers/private/kernel src/system/kernel/debug Message-ID: <200802041754.m14Hsfkg015311@sheep.berlios.de> Author: bonefish Date: 2008-02-04 18:54:40 +0100 (Mon, 04 Feb 2008) New Revision: 23864 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23864&view=rev Modified: haiku/trunk/headers/private/kernel/tracing.h haiku/trunk/src/system/kernel/debug/tracing.cpp Log: * Removed AbstractTraceEntry::sPrintTeamID and added a flags field to TraceOutput for output options instead. * Added "traced" option --difftime. Instead of the absolute system time it prints the difference time to the previously printed entry. Modified: haiku/trunk/headers/private/kernel/tracing.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing.h 2008-02-04 15:01:34 UTC (rev 23863) +++ haiku/trunk/headers/private/kernel/tracing.h 2008-02-04 17:54:40 UTC (rev 23864) @@ -20,9 +20,18 @@ #include + +// trace output flags +#define TRACE_OUTPUT_TEAM_ID 0x01 + // print the team ID +#define TRACE_OUTPUT_DIFF_TIME 0x02 + // print the difference time to the previously printed entry instead of the + // absolute time + + class TraceOutput { public: - TraceOutput(char* buffer, size_t bufferSize); + TraceOutput(char* buffer, size_t bufferSize, uint32 flags); void Clear(); void Print(const char* format,...); @@ -32,10 +41,17 @@ size_t Capacity() const { return fCapacity; } size_t Size() const { return fSize; } + uint32 Flags() const { return fFlags; } + + void SetLastEntryTime(bigtime_t time); + bigtime_t LastEntryTime() const; + private: - char* fBuffer; - size_t fCapacity; - size_t fSize; + char* fBuffer; + size_t fCapacity; + size_t fSize; + uint32 fFlags; + bigtime_t fLastEntryTime; }; class TraceEntry : public trace_entry { @@ -66,9 +82,6 @@ thread_id Team() const { return fTeam; } bigtime_t Time() const { return fTime; } - public: - static bool sPrintTeamID; - protected: thread_id fThread; team_id fTeam; Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-04 15:01:34 UTC (rev 23863) +++ haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-04 17:54:40 UTC (rev 23864) @@ -207,9 +207,10 @@ // #pragma mark - -TraceOutput::TraceOutput(char* buffer, size_t bufferSize) +TraceOutput::TraceOutput(char* buffer, size_t bufferSize, uint32 flags) : fBuffer(buffer), - fCapacity(bufferSize) + fCapacity(bufferSize), + fFlags(flags) { Clear(); } @@ -237,6 +238,20 @@ } +void +TraceOutput::SetLastEntryTime(bigtime_t time) +{ + fLastEntryTime = time; +} + + +bigtime_t +TraceOutput::LastEntryTime() const +{ + return fLastEntryTime; +} + + // #pragma mark - @@ -300,11 +315,18 @@ void AbstractTraceEntry::Dump(TraceOutput& out) { - if (sPrintTeamID) - out.Print("[%6ld:%6ld] %Ld: ", fThread, fTeam, fTime); + bigtime_t time = (out.Flags() & TRACE_OUTPUT_DIFF_TIME) + ? fTime - out.LastEntryTime() + : fTime; + + if (out.Flags() & TRACE_OUTPUT_TEAM_ID) + out.Print("[%6ld:%6ld] %10Ld: ", fThread, fTeam, time); else - out.Print("[%6ld] %Ld: ", fThread, fTime); + out.Print("[%6ld] %10Ld: ", fThread, time); + AddDump(out); + + out.SetLastEntryTime(fTime); } @@ -314,9 +336,6 @@ } -bool AbstractTraceEntry::sPrintTeamID = false; - - // #pragma mark - @@ -348,8 +367,8 @@ class LazyTraceOutput : public TraceOutput { public: - LazyTraceOutput(char* buffer, size_t bufferSize) - : TraceOutput(buffer, bufferSize) + LazyTraceOutput(char* buffer, size_t bufferSize, uint32 flags) + : TraceOutput(buffer, bufferSize, flags) { } @@ -703,6 +722,7 @@ static int32 _previousDirection = 1; static uint32 _previousWritten = 0; static uint32 _previousEntries = 0; + static uint32 _previousOutputFlags = 0; static TraceEntryIterator iterator; @@ -714,12 +734,16 @@ bool hasFilter = false; - AbstractTraceEntry::sPrintTeamID = false; - if (argi < argc) { + uint32 outputFlags = 0; + while (argi < argc) { if (strcmp(argv[argi], "--printteam") == 0) { - AbstractTraceEntry::sPrintTeamID = true; + outputFlags |= TRACE_OUTPUT_TEAM_ID; argi++; - } + } else if (strcmp(argv[argi], "--difftime") == 0) { + outputFlags |= TRACE_OUTPUT_DIFF_TIME; + argi++; + } else + break; } if (argi < argc) { @@ -783,6 +807,7 @@ count = _previousCount; maxToCheck = _previousMaxToCheck; hasFilter = _previousHasFilter; + outputFlags = _previousOutputFlags; if (direction < 0) start = _previousFirstChecked - 1; @@ -830,7 +855,7 @@ } char buffer[256]; - LazyTraceOutput out(buffer, sizeof(buffer)); + LazyTraceOutput out(buffer, sizeof(buffer), outputFlags); bool markedMatching = false; int32 firstToDump = firstToCheck; @@ -875,6 +900,8 @@ iterator.Previous(); } + out.SetLastEntryTime(0); + // set the iterator to the entry before the first one to dump iterator.MoveTo(firstToDump - 1); @@ -920,6 +947,7 @@ _previousDirection = direction; _previousWritten = sWritten; _previousEntries = sEntries; + _previousOutputFlags = outputFlags; return cont != 0 ? B_KDEBUG_CONT : 0; } @@ -1012,7 +1040,7 @@ add_debugger_command_etc("traced", &dump_tracing, "Dump recorded trace entries", - "[ \"--printteam\" ] (\"forward\" | \"backward\") " + "[ \"--printteam\" ] [ \"--difftime\" ] (\"forward\" | \"backward\") " "| ([ [ [ ] ] ] " "[ # | (\"filter\" ) ])\n" "Prints recorded trace entries. If \"backward\" or \"forward\" is\n" @@ -1022,7 +1050,8 @@ "afterwards entering an empty line in the debugger will reinvoke it.\n" "If no arguments are given, the command continues in the direction\n" "of the last invocation.\n" - "\"--printteam\" enables printing the items' team ID.\n" + "\"--printteam\" enables printing the entries' team IDs.\n" + "\"--difftime\" print difference times for all but the first entry.\n" " - The base index of the entries to print. Depending on\n" " whether the iteration direction is forward or\n" " backward this will be the first or last entry printed\n" From bonefish at mail.berlios.de Mon Feb 4 22:12:19 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 4 Feb 2008 22:12:19 +0100 Subject: [Haiku-commits] r23865 - haiku/trunk/src/kits/app Message-ID: <200802042112.m14LCJji015627@sheep.berlios.de> Author: bonefish Date: 2008-02-04 22:12:19 +0100 (Mon, 04 Feb 2008) New Revision: 23865 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23865&view=rev Modified: haiku/trunk/src/kits/app/Looper.cpp Log: _PostMessage() was holding the BLooperList lock while calling BMessenger::SendMessage(), which could lead to deadlocks (as in bug #1745). Modified: haiku/trunk/src/kits/app/Looper.cpp =================================================================== --- haiku/trunk/src/kits/app/Looper.cpp 2008-02-04 17:54:40 UTC (rev 23864) +++ haiku/trunk/src/kits/app/Looper.cpp 2008-02-04 21:12:19 UTC (rev 23865) @@ -829,6 +829,7 @@ status_t status; BMessenger messenger(handler, this, &status); + listLocker.Unlock(); if (status == B_OK) status = messenger.SendMessage(msg, replyTo, 0); From mmlr at mail.berlios.de Mon Feb 4 22:53:57 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 4 Feb 2008 22:53:57 +0100 Subject: [Haiku-commits] r23866 - haiku/trunk/src/system/kernel Message-ID: <200802042153.m14Lrvdx019484@sheep.berlios.de> Author: mmlr Date: 2008-02-04 22:53:57 +0100 (Mon, 04 Feb 2008) New Revision: 23866 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23866&view=rev Modified: haiku/trunk/src/system/kernel/heap.c Log: * Fix some coding style issues * Stumbled upon a possible bug while trying to understand the reuse of large allocations. The "first" variable was always set to the current index at the end of the loop, even if it was already set. This should have caused that the success condition to never be reached. Modified: haiku/trunk/src/system/kernel/heap.c =================================================================== --- haiku/trunk/src/system/kernel/heap.c 2008-02-04 21:12:19 UTC (rev 23865) +++ haiku/trunk/src/system/kernel/heap.c 2008-02-04 21:53:57 UTC (rev 23866) @@ -469,25 +469,24 @@ if (size < (heap_base_ptr - heap_base) / 10) { // but don't try too hard int first = -1; page = heap_alloc_table; - for (i = 0; i < (heap_base_ptr-heap_base)/B_PAGE_SIZE; i++) { + for (i = 0; i < (heap_base_ptr - heap_base) / B_PAGE_SIZE; i++) { if (page[i].in_use) { first = -1; continue; } if (first > 0) { - if ((1 + i - first)*B_PAGE_SIZE > size) + if ((1 + i - first) * B_PAGE_SIZE > size) break; - } - first = i; + } else + first = i; } if (first > -1) address = (void *)(heap_base + first * B_PAGE_SIZE); - } if (address == NULL) address = raw_alloc(size, bin_index); page = &heap_alloc_table[((unsigned int)address - heap_base) / B_PAGE_SIZE]; - for (i = 0; i < (size+B_PAGE_SIZE-1)/B_PAGE_SIZE; i++) { + for (i = 0; i < (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE; i++) { page[i].in_use = 1; page[i].cleaning = 0; page[i].bin_index = bin_count; @@ -640,7 +639,7 @@ // free this allocation anymore... (tracking them would // require some extra stuff) - for (i = 1; i <= (heap_base_ptr-heap_base)/B_PAGE_SIZE; i++) { + for (i = 1; i <= (heap_base_ptr - heap_base) / B_PAGE_SIZE; i++) { if (!page[i].in_use) break; if (page[i].bin_index != bin_count) From revol at free.fr Tue Feb 5 00:20:43 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Tue, 05 Feb 2008 00:20:43 +0100 CET Subject: [Haiku-commits] r23866 - haiku/trunk/src/system/kernel In-Reply-To: <200802042153.m14Lrvdx019484@sheep.berlios.de> Message-ID: <7095434837-BeMail@laptop> > * Stumbled upon a possible bug while trying to understand the reuse > of large > allocations. The "first" variable was always set to the current > index > at the > end of the loop, even if it was already set. This should have > caused that > the success condition to never be reached. Eh, I was quite frustrated when I wrote it, and I was just happy it appeared to work :) Fran?ois. From stefano.ceccherini at gmail.com Tue Feb 5 08:45:32 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Tue, 5 Feb 2008 08:45:32 +0100 Subject: [Haiku-commits] r23865 - haiku/trunk/src/kits/app In-Reply-To: <200802042112.m14LCJji015627@sheep.berlios.de> References: <200802042112.m14LCJji015627@sheep.berlios.de> Message-ID: <894b9700802042345o562832d3pf6503127938bde38@mail.gmail.com> 2008/2/4, bonefish at BerliOS : > Author: bonefish > Date: 2008-02-04 22:12:19 +0100 (Mon, 04 Feb 2008) > New Revision: 23865 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23865&view=rev > > Modified: > haiku/trunk/src/kits/app/Looper.cpp > Log: > _PostMessage() was holding the BLooperList lock while calling > BMessenger::SendMessage(), which could lead to deadlocks (as in bug > #1745). Hey, turns out I wasn't completely wrong then :) http://www.freelists.org/archives/haiku-development/01-2008/msg00006.html From stippi at mail.berlios.de Tue Feb 5 09:00:09 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 09:00:09 +0100 Subject: [Haiku-commits] r23867 - haiku/trunk/src/kits/media Message-ID: <200802050800.m15809d5031773@sheep.berlios.de> Author: stippi Date: 2008-02-05 09:00:08 +0100 (Tue, 05 Feb 2008) New Revision: 23867 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23867&view=rev Modified: haiku/trunk/src/kits/media/TimeSource.cpp Log: applied patch by Maurice Kalinowski: * BTimeSource now checks if it is about to add itself as a slave node and refuses to. Modified: haiku/trunk/src/kits/media/TimeSource.cpp =================================================================== --- haiku/trunk/src/kits/media/TimeSource.cpp 2008-02-04 21:53:57 UTC (rev 23866) +++ haiku/trunk/src/kits/media/TimeSource.cpp 2008-02-05 08:00:08 UTC (rev 23867) @@ -499,6 +499,10 @@ ERROR("BTimeSource::DirectAddMe out of slave node slots\n"); return; } + if (fNodeID == node.node) { + ERROR("BTimeSource::DirectAddMe should not add itself to slave nodes\n"); + return; + } for (int i = 0; i < SLAVE_NODES_COUNT; i++) { if (fSlaveNodes->node_id[i] == 0) { fSlaveNodes->node_id[i] = node.node; From stippi at mail.berlios.de Tue Feb 5 09:04:04 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 09:04:04 +0100 Subject: [Haiku-commits] r23868 - haiku/trunk/src/kits/media Message-ID: <200802050804.m15844Mb032492@sheep.berlios.de> Author: stippi Date: 2008-02-05 09:04:03 +0100 (Tue, 05 Feb 2008) New Revision: 23868 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23868&view=rev Modified: haiku/trunk/src/kits/media/DefaultMediaTheme.cpp Log: First part of a patch sent by Clemens zeidler: * The BMediaTheme now uses B_WIDTH_FROM_LABEL for tabs in tabviews, this makes tabs as wide as they need to be. Modified: haiku/trunk/src/kits/media/DefaultMediaTheme.cpp =================================================================== --- haiku/trunk/src/kits/media/DefaultMediaTheme.cpp 2008-02-05 08:00:08 UTC (rev 23867) +++ haiku/trunk/src/kits/media/DefaultMediaTheme.cpp 2008-02-05 08:04:03 UTC (rev 23868) @@ -67,7 +67,7 @@ class TabView : public BTabView { public: - TabView(BRect frame, const char *name, button_width width = B_WIDTH_AS_USUAL, + TabView(BRect frame, const char *name, button_width width = B_WIDTH_FROM_LABEL, uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); From stippi at mail.berlios.de Tue Feb 5 09:07:22 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 09:07:22 +0100 Subject: [Haiku-commits] r23869 - haiku/trunk/src/kits/interface Message-ID: <200802050807.m1587M0b000046@sheep.berlios.de> Author: stippi Date: 2008-02-05 09:07:21 +0100 (Tue, 05 Feb 2008) New Revision: 23869 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23869&view=rev Modified: haiku/trunk/src/kits/interface/TabView.cpp Log: Second part of a patch sent by Clemens zeidler: * If in B_WIDTH_AS_USUAL mode, the strings in the tabs are nevertheless truncated to the available width. * Pass the real area available for the string to BTab::DrawLabel(), resolved TODO in DrawLabel() about not having to calculate an offset to account for the slope. * Fixed some too lines of code. Modified: haiku/trunk/src/kits/interface/TabView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TabView.cpp 2008-02-05 08:04:03 UTC (rev 23868) +++ haiku/trunk/src/kits/interface/TabView.cpp 2008-02-05 08:07:21 UTC (rev 23869) @@ -6,16 +6,17 @@ * Marc Flerackers (mflerackers at androme.be) * J?r?me Duval (korli at users.berlios.de) */ +#include + +#include + #include #include #include #include -#include -//#include +#include -#include - static property_info sPropertyList[] = { { "Selection", @@ -204,24 +205,39 @@ owner->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); // TODO: remove offset float offset = frame.Height() / 2.0; - owner->StrokeLine(BPoint((frame.left + frame.right - width + offset) / 2.0, frame.bottom - 3), - BPoint((frame.left + frame.right + width + offset) / 2.0, frame.bottom - 3)); + owner->StrokeLine(BPoint((frame.left + frame.right - width + offset) / 2.0, + frame.bottom - 3), + BPoint((frame.left + frame.right + width + offset) / 2.0, + frame.bottom - 3)); } void BTab::DrawLabel(BView *owner, BRect frame) { - const char *label = Label(); - if (label == NULL) + if (Label() == NULL) return; + BString label = Label(); + float frameWidth = frame.Width(); + float width = owner->StringWidth(label.String()); + font_height fh; + + if (width > frameWidth) { + BFont font; + owner->GetFont(&font); + font.TruncateString(&label, B_TRUNCATE_END, frameWidth); + width = frameWidth; + font.GetHeight(&fh); + } else { + owner->GetFontHeight(&fh); + } + owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR)); - float width = owner->StringWidth(label); - // TODO: remove offset - float offset = frame.Height() / 2.0; - owner->DrawString(label, BPoint((frame.left + frame.right - width + offset) / 2.0, - frame.bottom - 4.0f - 2.0f)); + owner->DrawString(label.String(), + BPoint((frame.left + frame.right - width) / 2.0, + (frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0 + + fh.ascent)); } @@ -237,7 +253,11 @@ owner->SetHighColor(darkenmax); owner->SetLowColor(no_tint); - DrawLabel(owner, frame); + // NOTE: "frame" goes from the beginning of the left slope to the beginning + // of the right slope - "lableFrame" is the frame between both slopes + BRect lableFrame = frame; + lableFrame.left = lableFrame.left + frame.Height() / 2.0; + DrawLabel(owner, lableFrame); owner->SetDrawingMode(B_OP_OVER); @@ -248,37 +268,39 @@ if (position != B_TAB_ANY) { // full height left side owner->AddLine(BPoint(frame.left, frame.bottom), - BPoint(frame.left + slopeWidth, frame.top), darken3); + BPoint(frame.left + slopeWidth, frame.top), darken3); owner->AddLine(BPoint(frame.left, frame.bottom + 1), - BPoint(frame.left + slopeWidth, frame.top + 1), lightenmax); + BPoint(frame.left + slopeWidth, frame.top + 1), lightenmax); } else { // upper half of left side - owner->AddLine(BPoint(frame.left + slopeWidth / 2, frame.bottom - slopeWidth), - BPoint(frame.left + slopeWidth, frame.top), darken3); - owner->AddLine(BPoint(frame.left + slopeWidth / 2 + 2, frame.bottom - slopeWidth - 1), - BPoint(frame.left + slopeWidth, frame.top + 1), lightenmax); + owner->AddLine(BPoint(frame.left + slopeWidth / 2, + frame.bottom - slopeWidth), + BPoint(frame.left + slopeWidth, frame.top), darken3); + owner->AddLine(BPoint(frame.left + slopeWidth / 2 + 2, + frame.bottom - slopeWidth - 1), + BPoint(frame.left + slopeWidth, frame.top + 1), lightenmax); } // lines along the top owner->AddLine(BPoint(frame.left + slopeWidth, frame.top), - BPoint(frame.right, frame.top), darken3); + BPoint(frame.right, frame.top), darken3); owner->AddLine(BPoint(frame.left + slopeWidth, frame.top + 1), - BPoint(frame.right, frame.top + 1), lightenmax); + BPoint(frame.right, frame.top + 1), lightenmax); if (full) { // full height right side owner->AddLine(BPoint(frame.right, frame.top), - BPoint(frame.right + slopeWidth + 2, frame.bottom), darken2); + BPoint(frame.right + slopeWidth + 2, frame.bottom), darken2); owner->AddLine(BPoint(frame.right, frame.top + 1), - BPoint(frame.right + slopeWidth + 1, frame.bottom), darken4); + BPoint(frame.right + slopeWidth + 1, frame.bottom), darken4); } else { // upper half of right side owner->AddLine(BPoint(frame.right, frame.top), - BPoint(frame.right + slopeWidth / 2 + 1, - frame.bottom - slopeWidth), darken2); + BPoint(frame.right + slopeWidth / 2 + 1, + frame.bottom - slopeWidth), darken2); owner->AddLine(BPoint(frame.right, frame.top + 1), - BPoint(frame.right + slopeWidth / 2, - frame.bottom - slopeWidth), darken4); + BPoint(frame.right + slopeWidth / 2, + frame.bottom - slopeWidth), darken4); } owner->EndLineArray(); From axeld at mail.berlios.de Tue Feb 5 09:36:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Feb 2008 09:36:02 +0100 Subject: [Haiku-commits] r23870 - haiku/trunk/src/kits/interface Message-ID: <200802050836.m158a2OE002653@sheep.berlios.de> Author: axeld Date: 2008-02-05 09:36:01 +0100 (Tue, 05 Feb 2008) New Revision: 23870 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23870&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: UpdateIfNeeded() no longer keeps the looper's BMessageQueue locked when calling DispatchMessage(). Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-02-05 08:07:21 UTC (rev 23869) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-02-05 08:36:01 UTC (rev 23870) @@ -1698,27 +1698,25 @@ _DequeueAll(); BMessageQueue *queue = MessageQueue(); - queue->Lock(); // First process and remove any _UPDATE_ message in the queue // With the current design, there can only be one at a time - BMessage *msg; - for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { - if (msg->what == _UPDATE_) { - BWindow::DispatchMessage(msg, this); - // we need to make sure that no overridden method is called - // here; for BWindow::DispatchMessage() we now exactly what - // will happen - queue->RemoveMessage(msg); - delete msg; + while (true) { + queue->Lock(); + + BMessage *message = queue->FindMessage(_UPDATE_, 0); + queue->RemoveMessage(message); + + queue->Unlock(); + + if (message == NULL) break; - // NOTE: "i" would have to be decreased if there were - // multiple _UPDATE_ messages and we would not break! - } + + BWindow::DispatchMessage(message, this); + delete message; } - queue->Unlock(); Unlock(); } From stippi at mail.berlios.de Tue Feb 5 10:23:06 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 10:23:06 +0100 Subject: [Haiku-commits] r23871 - haiku/trunk/src/kits/tracker Message-ID: <200802050923.m159N6SI007389@sheep.berlios.de> Author: stippi Date: 2008-02-05 10:23:05 +0100 (Tue, 05 Feb 2008) New Revision: 23871 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23871&view=rev Modified: haiku/trunk/src/kits/tracker/PoseView.cpp haiku/trunk/src/kits/tracker/PoseView.h Log: Make the Desktop window check the Deskbar frame only every half a second, use a cached value otherwise. Should speed up icon placement when Tracker starts. Modified: haiku/trunk/src/kits/tracker/PoseView.cpp =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.cpp 2008-02-05 08:36:01 UTC (rev 23870) +++ haiku/trunk/src/kits/tracker/PoseView.cpp 2008-02-05 09:23:05 UTC (rev 23871) @@ -215,7 +215,9 @@ fShouldAutoScroll(true), fIsDesktopWindow(false), fIsWatchingDateFormatChange(false), - fHasPosesInClipboard(false) + fHasPosesInClipboard(false), + fLastDeskbarFrameCheckTime(LONGLONG_MIN), + fDeskbarFrame(0, 0, -1, -1) { fViewState->SetViewMode(viewMode); fShowSelectionWhenInactive = TrackerSettings().ShowSelectionWhenInactive(); @@ -3122,7 +3124,7 @@ BRect deskbarFrame; bool checkDeskbarFrame = false; - if (IsDesktopWindow() && get_deskbar_frame(&deskbarFrame) == B_OK) { + if (IsDesktopWindow() && GetDeskbarFrame(&deskbarFrame) == B_OK) { checkDeskbarFrame = true; deskbarFrame.InsetBy(-10, -10); } @@ -3143,6 +3145,23 @@ } +status_t +BPoseView::GetDeskbarFrame(BRect* frame) +{ + // only really check the Deskbar frame every half a second, + // use a cached value otherwise + status_t ret = B_OK; + bigtime_t now = system_time(); + if (fLastDeskbarFrameCheckTime + 500000 < now) { + // it's time to check the Deskbar frame again + ret = get_deskbar_frame(&fDeskbarFrame); + fLastDeskbarFrameCheckTime = now; + } + *frame = fDeskbarFrame; + return ret; +} + + void BPoseView::CheckAutoPlacedPoses() { Modified: haiku/trunk/src/kits/tracker/PoseView.h =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.h 2008-02-05 08:36:01 UTC (rev 23870) +++ haiku/trunk/src/kits/tracker/PoseView.h 2008-02-05 09:23:05 UTC (rev 23871) @@ -456,6 +456,7 @@ // find poses that need placing and place them in a new spot void PlacePose(BPose *, BRect &); // find a new place for a pose, starting at fHintLocation and place it + status_t GetDeskbarFrame(BRect* frame); bool SlotOccupied(BRect poseRect, BRect viewBounds) const; void NextSlot(BPose *, BRect &poseRect, BRect viewBounds); void TrySettingPoseLocation(BNode *node, BPoint point); @@ -659,6 +660,9 @@ static char sMatchString[B_FILE_NAME_LENGTH]; // used for typeahead - should be replaced by a typeahead state + bigtime_t fLastDeskbarFrameCheckTime; + BRect fDeskbarFrame; + // TODO: Get rid of this. static _BWidthBuffer_ *sWidthBuffer; From superstippi at gmx.de Tue Feb 5 11:53:58 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 05 Feb 2008 11:53:58 +0100 Subject: [Haiku-commits] r23865 - haiku/trunk/src/kits/app In-Reply-To: <894b9700802042345o562832d3pf6503127938bde38@mail.gmail.com> References: <200802042112.m14LCJji015627@sheep.berlios.de> <894b9700802042345o562832d3pf6503127938bde38@mail.gmail.com> Message-ID: <20080205115358.19699.7@stippis2.1202197869.fake> Stefano Ceccherini wrote (2008-02-05, 08:45:32 [+0100]): > 2008/2/4, bonefish at BerliOS : > > Author: bonefish > > Date: 2008-02-04 22:12:19 +0100 (Mon, 04 Feb 2008) New Revision: 23865 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23865&view=rev > > > > Modified: > > haiku/trunk/src/kits/app/Looper.cpp > > Log: > > _PostMessage() was holding the BLooperList lock while calling > > BMessenger::SendMessage(), which could lead to deadlocks (as in bug > > #1745). > > Hey, turns out I wasn't completely wrong then :) > http://www.freelists.org/archives/haiku-development/01-2008/msg00006.html Now that you mention it... the last time I played with Clockwerk on Haiku, it also locked up in UpdateIfNeeded(). Nice catch, Ingo (both of them)! Best regards, -Stephan From axeld at mail.berlios.de Tue Feb 5 12:21:10 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Feb 2008 12:21:10 +0100 Subject: [Haiku-commits] r23872 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda Message-ID: <200802051121.m15BLA6v019206@sheep.berlios.de> Author: axeld Date: 2008-02-05 12:21:07 +0100 (Tue, 05 Feb 2008) New Revision: 23872 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23872&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.c haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.c haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.c haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hooks.c Log: * Removed B_CAN_INTERRUPT from acquire_sem_etc() call in hda_send_verbs(); that doesn't look right to me (and since there is a 50 ms timeout anyway...). * Minor coding style cleanup. Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c 2008-02-05 09:23:05 UTC (rev 23871) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.c 2008-02-05 11:21:07 UTC (rev 23872) @@ -1,110 +1,114 @@ +/* + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar Adema, ithamar AT unet DOT nl + */ + + #include "driver.h" -hda_controller cards[MAXCARDS]; -uint32 num_cards; int32 api_version = B_CUR_DRIVER_API_VERSION; -pci_module_info* pci; +hda_controller gCards[MAXCARDS]; +uint32 gNumCards; +pci_module_info* gPci; -const char** publish_devices(void); /* Just to silence compiler */ status_t init_hardware(void) { - pci_info pcii; - status_t rc; + pci_info info; long i; - if ((rc=get_module(B_PCI_MODULE_NAME, (module_info**)&pci)) == B_OK) { - for (i=0; pci->get_nth_pci_info(i,&pcii) == B_OK; i++) { - if (pcii.class_base == PCI_multimedia && pcii.class_sub == PCI_hd_audio) { - put_module(B_PCI_MODULE_NAME); - pci = NULL; - return B_OK; - } + if (get_module(B_PCI_MODULE_NAME, (module_info**)&gPci) != B_OK) + return ENODEV; + + for (i = 0; gPci->get_nth_pci_info(i, &info) == B_OK; i++) { + if (info.class_base == PCI_multimedia + && info.class_sub == PCI_hd_audio) { + put_module(B_PCI_MODULE_NAME); + return B_OK; } - - put_module(B_PCI_MODULE_NAME); } - pci = NULL; - + put_module(B_PCI_MODULE_NAME); return ENODEV; } + status_t -init_driver (void) +init_driver(void) { char path[B_PATH_NAME_LENGTH]; - pci_info pcii; - status_t rc; + pci_info info; long i; - num_cards = 0; + if (get_module(B_PCI_MODULE_NAME, (module_info**)&gPci) != B_OK) + return ENODEV; - if ((rc=get_module(B_PCI_MODULE_NAME, (module_info**)&pci)) == B_OK) { - for (i=0; pci->get_nth_pci_info(i,&pcii) == B_OK; i++) { - if (pcii.class_base == PCI_multimedia && pcii.class_sub == PCI_hd_audio) { - cards[num_cards].pcii = pcii; - cards[num_cards].opened = 0; - sprintf(path, DEVFS_PATH_FORMAT, num_cards); - cards[num_cards++].devfs_path = strdup(path); - - dprintf("HDA: Detected controller @ PCI:%d:%d:%d, IRQ:%d, type %04x/%04x\n", - pcii.bus, pcii.device, pcii.function, - pcii.u.h0.interrupt_line, - pcii.vendor_id, pcii.device_id); - } + gNumCards = 0; + + for (i = 0; gPci->get_nth_pci_info(i, &info) == B_OK; i++) { + if (info.class_base == PCI_multimedia + && info.class_sub == PCI_hd_audio) { + gCards[gNumCards].pci_info = info; + gCards[gNumCards].opened = 0; + sprintf(path, DEVFS_PATH_FORMAT, gNumCards); + gCards[gNumCards++].devfs_path = strdup(path); + + dprintf("HDA: Detected controller @ PCI:%d:%d:%d, IRQ:%d, type %04x/%04x\n", + info.bus, info.device, info.function, + info.u.h0.interrupt_line, + info.vendor_id, info.device_id); } - } else { - return rc; } - if (num_cards == 0) { + if (gNumCards == 0) { put_module(B_PCI_MODULE_NAME); - pci = NULL; - return ENODEV; } return B_OK; } + void -uninit_driver (void) +uninit_driver(void) { long i; dprintf("IRA: %s\n", __func__); - for (i=0; i < num_cards; i++) { - free((void*)cards[i].devfs_path); - cards[i].devfs_path = NULL; + + for (i = 0; i < gNumCards; i++) { + free((void*)gCards[i].devfs_path); + gCards[i].devfs_path = NULL; } - if (pci != NULL) { - put_module(B_PCI_MODULE_NAME); - pci = NULL; - } + put_module(B_PCI_MODULE_NAME); } + const char** publish_devices(void) { static const char* devs[MAXCARDS+1]; long i; - + dprintf("IRA: %s\n", __func__); - for (i=0; i < num_cards; i++) - devs[i] = cards[i].devfs_path; + for (i = 0; i < gNumCards; i++) + devs[i] = gCards[i].devfs_path; devs[i] = NULL; return devs; } + device_hooks* find_device(const char* name) { dprintf("IRA: %s\n", __func__); - return &driver_hooks; + return &gDriverHooks; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-02-05 09:23:05 UTC (rev 23871) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-02-05 11:21:07 UTC (rev 23872) @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar Adema, ithamar AT unet DOT nl + */ #ifndef _HDA_H_ #define _HDA_H_ @@ -158,7 +165,7 @@ hda_afg* afgs[HDA_MAXAFGS]; uint32 num_afgs; - struct hda_controller_s* ctrlr; + struct hda_controller_s* controller; }; /* hda_controller @@ -170,7 +177,7 @@ */ struct hda_controller_s { - pci_info pcii; + struct pci_info pci_info; vuint32 opened; const char* devfs_path; @@ -199,30 +206,30 @@ }; /* driver.c */ -extern device_hooks driver_hooks; -extern pci_module_info* pci; -extern hda_controller cards[MAXCARDS]; -extern uint32 num_cards; +extern device_hooks gDriverHooks; +extern pci_module_info* gPci; +extern hda_controller gCards[MAXCARDS]; +extern uint32 gNumCards; /* hda_codec.c */ -hda_codec* hda_codec_new(hda_controller* ctrlr, uint32 cad); +hda_codec* hda_codec_new(hda_controller* controller, uint32 cad); void hda_codec_delete(hda_codec*); /* hda_multi_audio.c */ status_t multi_audio_control(void* cookie, uint32 op, void* arg, size_t len); /* hda_controller.c: Basic controller support */ -status_t hda_hw_init(hda_controller* ctrlr); -void hda_hw_stop(hda_controller* ctrlr); -void hda_hw_uninit(hda_controller* ctrlr); +status_t hda_hw_init(hda_controller* controller); +void hda_hw_stop(hda_controller* controller); +void hda_hw_uninit(hda_controller* controller); status_t hda_send_verbs(hda_codec* codec, corb_t* verbs, uint32* responses, int count); /* hda_controller.c: Stream support */ -hda_stream* hda_stream_new(hda_controller* ctrlr, int type); +hda_stream* hda_stream_new(hda_controller* controller, int type); void hda_stream_delete(hda_stream* s); status_t hda_stream_setup_buffers(hda_afg* afg, hda_stream* s, const char* desc); -status_t hda_stream_start(hda_controller* ctrlr, hda_stream* s); -status_t hda_stream_stop(hda_controller* ctrlr, hda_stream* s); -status_t hda_stream_check_intr(hda_controller* ctrlr, hda_stream* s); +status_t hda_stream_start(hda_controller* controller, hda_stream* s); +status_t hda_stream_stop(hda_controller* controller, hda_stream* s); +status_t hda_stream_check_intr(hda_controller* controller, hda_stream* s); #endif /* _HDA_H_ */ Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.c 2008-02-05 09:23:05 UTC (rev 23871) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.c 2008-02-05 11:21:07 UTC (rev 23872) @@ -1,34 +1,47 @@ +/* + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar Adema, ithamar AT unet DOT nl + */ + + #include "driver.h" #include "hda_codec_defs.h" -const char* portcon[] = { + +static const char* kPortConnector[] = { "Jack", "None", "Fixed", "Dual" }; -const char* defdev[] = { - "Line Out", "Speaker", "HP Out", "CD", "SPDIF out", "Digital Other Out", "Modem Line Side", - "Modem Hand Side", "Line In", "AUX", "Mic In", "Telephony", "SPDIF In", "Digital Other In", - "Reserved", "Other" +static const char* kDefaultDevice[] = { + "Line Out", "Speaker", "HP Out", "CD", "SPDIF out", "Digital Other Out", + "Modem Line Side", "Modem Hand Side", "Line In", "AUX", "Mic In", + "Telephony", "SPDIF In", "Digital Other In", "Reserved", "Other" }; -const char* conntype[] = { - "N/A", "1/8\"", "1/4\"", "ATAPI internal", "RCA", "Optical", "Other Digital", "Other Analog", - "Multichannel Analog (DIN)", "XLR/Professional", "RJ-11 (Modem)", "Combination", "-", "-", "-", "Other" +static const char* kConnectionType[] = { + "N/A", "1/8\"", "1/4\"", "ATAPI internal", "RCA", "Optical", + "Other Digital", "Other Analog", "Multichannel Analog (DIN)", + "XLR/Professional", "RJ-11 (Modem)", "Combination", "-", "-", "-", "Other" }; -const char* jcolor[] = { - "N/A", "Black", "Grey", "Blue", "Green", "Red", "Orange", "Yellow", "Purple", "Pink", - "-", "-", "-", "-", "White", "Other" +static const char* kJackColor[] = { + "N/A", "Black", "Grey", "Blue", "Green", "Red", "Orange", "Yellow", + "Purple", "Pink", "-", "-", "-", "-", "White", "Other" }; + static status_t hda_widget_get_pm_support(hda_codec* codec, uint32 nid, uint32* pm) { - corb_t verb = MAKE_VERB(codec->addr,nid,VID_GET_PARAM,PID_POWERSTATE_SUPPORT); + corb_t verb = MAKE_VERB(codec->addr, nid, VID_GET_PARAM, + PID_POWERSTATE_SUPPORT); status_t rc; uint32 resp; - - if ((rc=hda_send_verbs(codec, &verb, &resp, 1)) == B_OK) { + + if ((rc = hda_send_verbs(codec, &verb, &resp, 1)) == B_OK) { *pm = 0; /* FIXME: Define constants for powermanagement modes */ @@ -37,12 +50,14 @@ if (resp & (1 << 2)) ; if (resp & (1 << 3)) ; } - + return rc; } + static status_t -hda_widget_get_stream_support(hda_codec* codec, uint32 nid, uint32* fmts, uint32* rates) +hda_widget_get_stream_support(hda_codec* codec, uint32 nid, uint32* fmts, + uint32* rates) { corb_t verbs[2]; uint32 resp[2]; @@ -50,56 +65,76 @@ verbs[0] = MAKE_VERB(codec->addr,nid,VID_GET_PARAM,PID_STREAM_SUPPORT); verbs[1] = MAKE_VERB(codec->addr,nid,VID_GET_PARAM,PID_PCM_SUPPORT); - if ((rc=hda_send_verbs(codec, verbs, resp, 2)) == B_OK) { + if ((rc = hda_send_verbs(codec, verbs, resp, 2)) == B_OK) { *fmts = 0; *rates = 0; if (resp[2] & (1 << 0)) { - if (resp[1] & (1 << 0)) *rates |= B_SR_8000; - if (resp[1] & (1 << 1)) *rates |= B_SR_11025; - if (resp[1] & (1 << 2)) *rates |= B_SR_16000; - if (resp[1] & (1 << 3)) *rates |= B_SR_22050; - if (resp[1] & (1 << 4)) *rates |= B_SR_32000; - if (resp[1] & (1 << 5)) *rates |= B_SR_44100; - if (resp[1] & (1 << 6)) *rates |= B_SR_48000; - if (resp[1] & (1 << 7)) *rates |= B_SR_88200; - if (resp[1] & (1 << 8)) *rates |= B_SR_96000; - if (resp[1] & (1 << 9)) *rates |= B_SR_176400; - if (resp[1] & (1 << 10)) *rates |= B_SR_192000; - if (resp[1] & (1 << 11)) *rates |= B_SR_384000; - - if (resp[1] & (1<<16)) *fmts |= B_FMT_8BIT_S; - if (resp[1] & (1<<17)) *fmts |= B_FMT_16BIT; - if (resp[1] & (1<<18)) *fmts |= B_FMT_18BIT; - if (resp[1] & (1<<19)) *fmts |= B_FMT_24BIT; - if (resp[1] & (1<<20)) *fmts |= B_FMT_32BIT; + if (resp[1] & (1 << 0)) + *rates |= B_SR_8000; + if (resp[1] & (1 << 1)) + *rates |= B_SR_11025; + if (resp[1] & (1 << 2)) + *rates |= B_SR_16000; + if (resp[1] & (1 << 3)) + *rates |= B_SR_22050; + if (resp[1] & (1 << 4)) + *rates |= B_SR_32000; + if (resp[1] & (1 << 5)) + *rates |= B_SR_44100; + if (resp[1] & (1 << 6)) + *rates |= B_SR_48000; + if (resp[1] & (1 << 7)) + *rates |= B_SR_88200; + if (resp[1] & (1 << 8)) + *rates |= B_SR_96000; + if (resp[1] & (1 << 9)) + *rates |= B_SR_176400; + if (resp[1] & (1 << 10)) + *rates |= B_SR_192000; + if (resp[1] & (1 << 11)) + *rates |= B_SR_384000; + + if (resp[1] & (1 << 16)) + *fmts |= B_FMT_8BIT_S; + if (resp[1] & (1 << 17)) + *fmts |= B_FMT_16BIT; + if (resp[1] & (1 << 18)) + *fmts |= B_FMT_18BIT; + if (resp[1] & (1 << 19)) + *fmts |= B_FMT_24BIT; + if (resp[1] & (1 << 20)) + *fmts |= B_FMT_32BIT; } -//FIXME: if (resp[0] & (1 << 1)) *fmts |= B_FMT_FLOAT; -//FIXME: if (resp[0] & (1 << 2)) /* Sort out how to handle AC3 */; +//FIXME: if (resp[0] & (1 << 1)) *fmts |= B_FMT_FLOAT; +//FIXME: if (resp[0] & (1 << 2)) /* Sort out how to handle AC3 */; } - + return rc; } + static status_t hda_widget_get_amplifier_capabilities(hda_codec* codec, uint32 nid) { status_t rc; corb_t verb; uint32 resp; - - verb = MAKE_VERB(codec->addr,nid,VID_GET_PARAM,PID_OUTPUT_AMP_CAP); - if ((rc=hda_send_verbs(codec, &verb, &resp, 1)) == B_OK && resp != 0) { + + verb = MAKE_VERB(codec->addr, nid, VID_GET_PARAM, PID_OUTPUT_AMP_CAP); + rc = hda_send_verbs(codec, &verb, &resp, 1); + if (rc == B_OK && resp != 0) { dprintf("\tAMP: Mute: %s, step size: %ld, # steps: %ld, offset: %ld\n", (resp & (1 << 31)) ? "supported" : "N/A", (resp >> 16) & 0x7F, (resp >> 8) & 0x7F, resp & 0x7F); } - + return rc; } + static status_t hda_codec_parse_afg(hda_afg* afg) { @@ -107,20 +142,25 @@ uint32 resp[6]; uint32 widx; - hda_widget_get_stream_support(afg->codec, afg->root_nid, &afg->deffmts, &afg->defrates); + hda_widget_get_stream_support(afg->codec, afg->root_nid, &afg->deffmts, + &afg->defrates); hda_widget_get_pm_support(afg->codec, afg->root_nid, &afg->defpm); - verbs[0] = MAKE_VERB(afg->codec->addr,afg->root_nid,VID_GET_PARAM,PID_AUDIO_FG_CAP); - verbs[1] = MAKE_VERB(afg->codec->addr,afg->root_nid,VID_GET_PARAM,PID_GPIO_COUNT); - verbs[2] = MAKE_VERB(afg->codec->addr,afg->root_nid,VID_GET_PARAM,PID_SUBORD_NODE_COUNT); + verbs[0] = MAKE_VERB(afg->codec->addr, afg->root_nid, VID_GET_PARAM, + PID_AUDIO_FG_CAP); + verbs[1] = MAKE_VERB(afg->codec->addr, afg->root_nid, VID_GET_PARAM, + PID_GPIO_COUNT); + verbs[2] = MAKE_VERB(afg->codec->addr, afg->root_nid, VID_GET_PARAM, + PID_SUBORD_NODE_COUNT); if (hda_send_verbs(afg->codec, verbs, resp, 3) == B_OK) { - dprintf("%s: Output delay: %ld samples, Input delay: %ld samples, Beep Generator: %s\n", __func__, - resp[0] & 0xf, (resp[0] >> 8) & 0xf, (resp[0] & (1 << 16)) ? "yes" : "no"); + dprintf("%s: Output delay: %ld samples, Input delay: %ld samples, " + "Beep Generator: %s\n", __func__, resp[0] & 0xf, + (resp[0] >> 8) & 0xf, (resp[0] & (1 << 16)) ? "yes" : "no"); - dprintf("%s: #GPIO: %ld, #GPO: %ld, #GPI: %ld, unsol: %s, wake: %s\n", __func__, - resp[4] & 0xFF, (resp[1] >> 8) & 0xFF, (resp[1] >> 16) & 0xFF, - (resp[1] & (1 << 30)) ? "yes" : "no", + dprintf("%s: #GPIO: %ld, #GPO: %ld, #GPI: %ld, unsol: %s, wake: %s\n", + __func__, resp[4] & 0xFF, (resp[1] >> 8) & 0xFF, + (resp[1] >> 16) & 0xFF, (resp[1] & (1 << 30)) ? "yes" : "no", (resp[1] & (1 << 31)) ? "yes" : "no"); afg->wid_start = resp[2] >> 16; @@ -133,20 +173,24 @@ } /* Iterate over all Widgets and collect info */ - for (widx=0; widx < afg->wid_count; widx++) { + for (widx = 0; widx < afg->wid_count; widx++) { uint32 wid = afg->wid_start + widx; char buf[256]; int off; - - verbs[0] = MAKE_VERB(afg->codec->addr,wid,VID_GET_PARAM,PID_AUDIO_WIDGET_CAP); - verbs[1] = MAKE_VERB(afg->codec->addr,wid,VID_GET_PARAM,PID_CONNLIST_LEN); + + verbs[0] = MAKE_VERB(afg->codec->addr, wid, VID_GET_PARAM, + PID_AUDIO_WIDGET_CAP); + verbs[1] = MAKE_VERB(afg->codec->addr, wid, VID_GET_PARAM, + PID_CONNLIST_LEN); hda_send_verbs(afg->codec, verbs, resp, 2); - + afg->widgets[widx].type = resp[0] >> 20; afg->widgets[widx].num_inputs = resp[1] & 0x7F; off = 0; - if (resp[0] & (1 << 11)) off += sprintf(buf+off, "[L-R Swap] "); + if (resp[0] & (1 << 11)) + off += sprintf(buf + off, "[L-R Swap] "); + if (resp[0] & (1 << 10)) { corb_t verb; uint32 resp; @@ -154,21 +198,30 @@ off += sprintf(buf+off, "[Power] "); /* We support power; switch us on! */ - verb = MAKE_VERB(afg->codec->addr,wid,VID_SET_POWERSTATE,0); + verb = MAKE_VERB(afg->codec->addr, wid, VID_SET_POWERSTATE, 0); hda_send_verbs(afg->codec, &verb, &resp, 1); } - if (resp[0] & (1 << 9)) off += sprintf(buf+off, "[Digital] "); - if (resp[0] & (1 << 7)) off += sprintf(buf+off, "[Unsol Capable] "); - if (resp[0] & (1 << 6)) off += sprintf(buf+off, "[Proc Widget] "); - if (resp[0] & (1 << 5)) off += sprintf(buf+off, "[Stripe] "); - if (resp[0] & (1 << 4)) off += sprintf(buf+off, "[Format Override] "); - if (resp[0] & (1 << 3)) off += sprintf(buf+off, "[Amp Param Override] "); - if (resp[0] & (1 << 2)) off += sprintf(buf+off, "[Out Amp] "); - if (resp[0] & (1 << 1)) off += sprintf(buf+off, "[In Amp] "); - if (resp[0] & (1 << 0)) off += sprintf(buf+off, "[Stereo] "); + if (resp[0] & (1 << 9)) + off += sprintf(buf + off, "[Digital] "); + if (resp[0] & (1 << 7)) + off += sprintf(buf + off, "[Unsol Capable] "); + if (resp[0] & (1 << 6)) + off += sprintf(buf + off, "[Proc Widget] "); + if (resp[0] & (1 << 5)) + off += sprintf(buf + off, "[Stripe] "); + if (resp[0] & (1 << 4)) + off += sprintf(buf + off, "[Format Override] "); + if (resp[0] & (1 << 3)) + off += sprintf(buf + off, "[Amp Param Override] "); + if (resp[0] & (1 << 2)) + off += sprintf(buf + off, "[Out Amp] "); + if (resp[0] & (1 << 1)) + off += sprintf(buf + off, "[In Amp] "); + if (resp[0] & (1 << 0)) + off += sprintf(buf + off, "[Stereo] "); - switch(afg->widgets[widx].type) { + switch (afg->widgets[widx].type) { case WT_AUDIO_OUTPUT: dprintf("%ld:\tAudio Output\n", wid); hda_widget_get_stream_support(afg->codec, wid, @@ -193,11 +246,12 @@ break; case WT_PIN_COMPLEX: dprintf("%ld:\tPin Complex\n", wid); - verbs[0] = MAKE_VERB(afg->codec->addr,wid,VID_GET_PARAM,PID_PIN_CAP); + verbs[0] = MAKE_VERB(afg->codec->addr, wid, VID_GET_PARAM, + PID_PIN_CAP); if (hda_send_verbs(afg->codec, verbs, resp, 1) == B_OK) { afg->widgets[widx].d.pin.input = resp[0] & (1 << 5); afg->widgets[widx].d.pin.output = resp[0] & (1 << 4); - + dprintf("\t%s%s\n", afg->widgets[widx].d.pin.input ? "[Input] " : "", afg->widgets[widx].d.pin.input ? "[Output]" : ""); @@ -205,16 +259,17 @@ dprintf("%s: Error getting Pin Complex IO\n", __func__); } - verbs[0] = MAKE_VERB(afg->codec->addr,wid,VID_GET_CFGDEFAULT,0); + verbs[0] = MAKE_VERB(afg->codec->addr, wid, + VID_GET_CFGDEFAULT, 0); if (hda_send_verbs(afg->codec, verbs, resp, 1) == B_OK) { afg->widgets[widx].d.pin.device = (resp[0] >> 20) & 0xF; dprintf("\t%s, %s, %s, %s\n", - portcon[resp[0] >> 30], - defdev[afg->widgets[widx].d.pin.device], - conntype[(resp[0] >> 16) & 0xF], - jcolor[(resp[0] >> 12) & 0xF]); + kPortConnector[resp[0] >> 30], + kDefaultDevice[afg->widgets[widx].d.pin.device], + kConnectionType[(resp[0] >> 16) & 0xF], + kJackColor[(resp[0] >> 12) & 0xF]); } - + hda_widget_get_amplifier_capabilities(afg->codec, wid); break; case WT_POWER: @@ -236,61 +291,66 @@ dprintf("\t%s\n", buf); hda_widget_get_pm_support(afg->codec, wid, &afg->widgets[widx].pm); - + if (afg->widgets[widx].num_inputs) { int idx; off = 0; if (afg->widgets[widx].num_inputs > 1) { - verbs[0] = MAKE_VERB(afg->codec->addr,wid,VID_GET_CONNSEL,0); + verbs[0] = MAKE_VERB(afg->codec->addr, wid, VID_GET_CONNSEL, + 0); if (hda_send_verbs(afg->codec, verbs, resp, 1) == B_OK) afg->widgets[widx].active_input = resp[0] & 0xFF; else afg->widgets[widx].active_input = -1; } else afg->widgets[widx].active_input = -1; - - for (idx=0; idx < afg->widgets[widx].num_inputs; idx ++) { + + for (idx = 0; idx < afg->widgets[widx].num_inputs; idx ++) { if (!(idx % 4)) { - verbs[0] = MAKE_VERB(afg->codec->addr,wid,VID_GET_CONNLENTRY,idx); + verbs[0] = MAKE_VERB(afg->codec->addr, wid, + VID_GET_CONNLENTRY, idx); if (hda_send_verbs(afg->codec, verbs, resp, 1) != B_OK) { - dprintf("%s: Error parsing inputs for widget %ld!\n", __func__, wid); + dprintf("%s: Error parsing inputs for widget %ld!\n", + __func__, wid); break; } } - if (idx != afg->widgets[widx].active_input) - off += sprintf(buf+off, "%ld ", (resp[0] >> (8*(idx%4))) & 0xFF); - else - off += sprintf(buf+off, "(%ld) ", (resp[0] >> (8*(idx%4))) & 0xFF); + if (idx != afg->widgets[widx].active_input) { + off += sprintf(buf + off, "%ld ", + (resp[0] >> (8*(idx%4))) & 0xFF); + } else { + off += sprintf(buf + off, "(%ld) ", + (resp[0] >> (8*(idx%4))) & 0xFF); + } - afg->widgets[widx].inputs[idx] = (resp[0] >> (8*(idx%4))) & 0xFF; + afg->widgets[widx].inputs[idx] = (resp[0] >> (8*(idx%4))) + & 0xFF; } - + dprintf("\t[ %s]\n", buf); } } } - + return B_OK; } -/* hda_codec_afg_find_path - * - * Find path from 'wid' to a widget of type 'wtype', returning its widget id. + +/*! Find path from 'wid' to a widget of type 'wtype', returning its widget id. * Returns 0 if not found. */ - static uint32 hda_codec_afg_find_path(hda_afg* afg, uint32 wid, uint32 wtype, uint32 depth) { int widx = wid - afg->wid_start; int idx; - switch(afg->widgets[widx].type) { + switch (afg->widgets[widx].type) { case WT_AUDIO_MIXER: - for (idx=0; idx < afg->widgets[widx].num_inputs; idx++) { + for (idx = 0; idx < afg->widgets[widx].num_inputs; idx++) { if (hda_codec_afg_find_path(afg, afg->widgets[widx].inputs[idx], wtype, depth +1)) { if (afg->widgets[widx].active_input == -1) afg->widgets[widx].active_input = idx; @@ -301,16 +361,16 @@ break; case WT_AUDIO_SELECTOR: - { - int idx = afg->widgets[widx].active_input; - if (idx != -1) { - uint32 wid = afg->widgets[widx].inputs[idx]; - if (hda_codec_afg_find_path(afg, wid, wtype, depth +1)) { - return wid; - } + { + int idx = afg->widgets[widx].active_input; + if (idx != -1) { + uint32 wid = afg->widgets[widx].inputs[idx]; + if (hda_codec_afg_find_path(afg, wid, wtype, depth + 1)) { + return wid; } } break; + } default: if (afg->widgets[widx].type == wtype) @@ -322,6 +382,7 @@ return 0; } + static void hda_afg_delete(hda_afg* afg) { @@ -339,6 +400,7 @@ } } + static status_t hda_codec_afg_new(hda_codec* codec, uint32 afg_nid) { @@ -346,7 +408,7 @@ status_t rc; uint32 idx; - if ((afg=calloc(1, sizeof(hda_afg))) == NULL) { + if ((afg = calloc(1, sizeof(hda_afg))) == NULL) { rc = B_NO_MEMORY; goto done; } @@ -360,94 +422,110 @@ if (rc != B_OK) goto free_afg; - /* Setup for worst-case scenario; - we cannot find any output Pin Widgets */ + /* Setup for worst-case scenario; we cannot find any output Pin Widgets */ rc = ENODEV; /* Try to locate all input/output channels */ - for (idx=0; idx < afg->wid_count; idx++) { + for (idx = 0; idx < afg->wid_count; idx++) { uint32 output_wid = 0, input_wid = 0; int32 iidx; - if (afg->playback_stream == NULL && afg->widgets[idx].type == WT_PIN_COMPLEX && afg->widgets[idx].d.pin.output) { - if (afg->widgets[idx].d.pin.device == PIN_DEV_HP_OUT || - afg->widgets[idx].d.pin.device == PIN_DEV_SPEAKER || - afg->widgets[idx].d.pin.device == PIN_DEV_LINE_OUT) - { - iidx = afg->widgets[idx].active_input; - if (iidx != -1) { - output_wid = hda_codec_afg_find_path(afg, afg->widgets[idx].inputs[iidx], WT_AUDIO_OUTPUT, 0); - } else { - for (iidx=0; iidx < afg->widgets[idx].num_inputs; iidx++) { - output_wid = hda_codec_afg_find_path(afg, afg->widgets[idx].inputs[iidx], WT_AUDIO_OUTPUT, 0); - if (output_wid) { - corb_t verb = MAKE_VERB(codec->addr,idx+afg->wid_start,VID_SET_CONNSEL,iidx); - if (hda_send_verbs(codec, &verb, NULL, 1) != B_OK) - dprintf("%s: Setting output selector failed!\n", __func__); - break; + if (afg->playback_stream == NULL + && afg->widgets[idx].type == WT_PIN_COMPLEX + && afg->widgets[idx].d.pin.output) { + if (afg->widgets[idx].d.pin.device == PIN_DEV_HP_OUT + || afg->widgets[idx].d.pin.device == PIN_DEV_SPEAKER + || afg->widgets[idx].d.pin.device == PIN_DEV_LINE_OUT) { + iidx = afg->widgets[idx].active_input; + if (iidx != -1) { + output_wid = hda_codec_afg_find_path(afg, + afg->widgets[idx].inputs[iidx], WT_AUDIO_OUTPUT, 0); + } else { + for (iidx = 0; iidx < afg->widgets[idx].num_inputs; iidx++) { + output_wid = hda_codec_afg_find_path(afg, + afg->widgets[idx].inputs[iidx], WT_AUDIO_OUTPUT, 0); + if (output_wid) { + corb_t verb = MAKE_VERB(codec->addr, + idx + afg->wid_start, VID_SET_CONNSEL, iidx); + if (hda_send_verbs(codec, &verb, NULL, 1) != B_OK) + dprintf("%s: Setting output selector failed!\n", __func__); + break; + } } } - } - - if (output_wid) { - if (!afg->playback_stream) { - corb_t verb[2]; - - /* Setup playback/record streams for Multi Audio API */ - afg->playback_stream = hda_stream_new(afg->codec->ctrlr, STRM_PLAYBACK); - afg->record_stream = hda_stream_new(afg->codec->ctrlr, STRM_RECORD); - - afg->playback_stream->pin_wid = idx + afg->wid_start; - afg->playback_stream->io_wid = output_wid; - - /* FIXME: Force Pin Widget to unmute; enable hp/output */ - verb[0] = MAKE_VERB(codec->addr, afg->playback_stream->pin_wid, - VID_SET_AMPGAINMUTE, (1 << 15) | (1 << 13) | (1 << 12)); - verb[1] = MAKE_VERB(codec->addr, afg->playback_stream->pin_wid, - VID_SET_PINWCTRL, (1 << 7) | (1 << 6)); - hda_send_verbs(codec, verb, NULL, 2); - dprintf("%s: Found output PIN (%s) connected to output CONV wid:%ld\n", - __func__, defdev[afg->widgets[idx].d.pin.device], output_wid); - } + if (output_wid) { + if (!afg->playback_stream) { + corb_t verb[2]; + + /* Setup playback/record streams for Multi Audio API */ + afg->playback_stream = hda_stream_new( + afg->codec->controller, STRM_PLAYBACK); + afg->record_stream = hda_stream_new( + afg->codec->controller, STRM_RECORD); + + afg->playback_stream->pin_wid = idx + afg->wid_start; + afg->playback_stream->io_wid = output_wid; + + /* FIXME: Force Pin Widget to unmute; enable hp/output */ + verb[0] = MAKE_VERB(codec->addr, + afg->playback_stream->pin_wid, VID_SET_AMPGAINMUTE, + (1 << 15) | (1 << 13) | (1 << 12)); + verb[1] = MAKE_VERB(codec->addr, + afg->playback_stream->pin_wid, VID_SET_PINWCTRL, + (1 << 7) | (1 << 6)); + hda_send_verbs(codec, verb, NULL, 2); + + dprintf("%s: Found output PIN (%s) connected to output " + "CONV wid:%ld\n", __func__, + kDefaultDevice[afg->widgets[idx].d.pin.device], output_wid); + } + } } - } } if (afg->widgets[idx].type == WT_AUDIO_INPUT) { iidx = afg->widgets[idx].active_input; if (iidx != -1) { - input_wid = hda_codec_afg_find_path(afg, afg->widgets[idx].inputs[iidx], WT_PIN_COMPLEX, 0); + input_wid = hda_codec_afg_find_path(afg, + afg->widgets[idx].inputs[iidx], WT_PIN_COMPLEX, 0); } else { - for (iidx=0; iidx < afg->widgets[idx].num_inputs; iidx++) { - input_wid = hda_codec_afg_find_path(afg, afg->widgets[idx].inputs[iidx], WT_PIN_COMPLEX, 0); + for (iidx = 0; iidx < afg->widgets[idx].num_inputs; iidx++) { + input_wid = hda_codec_afg_find_path(afg, + afg->widgets[idx].inputs[iidx], WT_PIN_COMPLEX, 0); if (input_wid) { - corb_t verb = MAKE_VERB(codec->addr,idx+afg->wid_start,VID_SET_CONNSEL,iidx); - if (hda_send_verbs(codec, &verb, NULL, 1) != B_OK) - dprintf("%s: Setting input selector failed!\n", __func__); + corb_t verb = MAKE_VERB(codec->addr, + idx + afg->wid_start, VID_SET_CONNSEL, iidx); + if (hda_send_verbs(codec, &verb, NULL, 1) != B_OK) { + dprintf("%s: Setting input selector failed!\n", + __func__); + } break; } } } - + if (input_wid) { if (!afg->record_stream) { corb_t verb; - + /* Setup playback/record streams for Multi Audio API */ - afg->record_stream = hda_stream_new(afg->codec->ctrlr, STRM_RECORD); - + afg->record_stream = hda_stream_new(afg->codec->controller, + STRM_RECORD); + afg->record_stream->pin_wid = input_wid; afg->record_stream->io_wid = idx + afg->wid_start; - + /* FIXME: Force Pin Widget to unmute */ verb = MAKE_VERB(codec->addr, afg->record_stream->pin_wid, VID_SET_AMPGAINMUTE, (1 << 15) | (1 << 13) | (1 << 12)); hda_send_verbs(codec, &verb, NULL, 1); } - - dprintf("%s: Found input PIN (%s) connected to input CONV wid:%ld\n", - __func__, defdev[afg->widgets[input_wid-afg->wid_start].d.pin.device], idx+afg->wid_start); + + dprintf("%s: Found input PIN (%s) connected to input CONV " + "wid:%ld\n", __func__, kDefaultDevice[afg->widgets[ + input_wid-afg->wid_start].d.pin.device], + idx + afg->wid_start); } } } @@ -466,6 +544,7 @@ return rc; } + void hda_codec_delete(hda_codec* codec) { @@ -474,7 +553,7 @@ delete_sem(codec->response_sem); - for (idx=0; idx < codec->num_afgs; idx++) { + for (idx = 0; idx < codec->num_afgs; idx++) { hda_afg_delete(codec->afgs[idx]); codec->afgs[idx] = NULL; } @@ -483,44 +562,45 @@ } } + hda_codec* -hda_codec_new(hda_controller* ctrlr, uint32 cad) +hda_codec_new(hda_controller* controller, uint32 cad) { hda_codec* codec = calloc(1, sizeof(hda_codec)); uint32 responses[3]; corb_t verbs[3]; - status_t rc; uint32 nid; - if (codec == NULL) goto exit_new; + if (codec == NULL) + goto exit_new; - codec->ctrlr = ctrlr; + codec->controller = controller; codec->addr = cad; codec->response_sem = create_sem(0, "hda_codec_response_sem"); - ctrlr->codecs[cad] = codec; - - verbs[0] = MAKE_VERB(cad,0,VID_GET_PARAM,PID_VENDORID); - verbs[1] = MAKE_VERB(cad,0,VID_GET_PARAM,PID_REVISIONID); - verbs[2] = MAKE_VERB(cad,0,VID_GET_PARAM,PID_SUBORD_NODE_COUNT); + controller->codecs[cad] = codec; + verbs[0] = MAKE_VERB(cad, 0, VID_GET_PARAM, PID_VENDORID); + verbs[1] = MAKE_VERB(cad, 0, VID_GET_PARAM, PID_REVISIONID); + verbs[2] = MAKE_VERB(cad, 0, VID_GET_PARAM, PID_SUBORD_NODE_COUNT); + if (hda_send_verbs(codec, verbs, responses, 3) != B_OK) goto cmd_failed; dprintf("Codec %ld Vendor: %04lx Product: %04lx\n", cad, responses[0] >> 16, responses[0] & 0xFFFF); - - for (nid=responses[2] >> 16; - nid < (responses[2] >> 16) + (responses[2] & 0xFF); - nid++) { + + for (nid = responses[2] >> 16; + nid < (responses[2] >> 16) + (responses[2] & 0xFF); nid++) { uint32 resp; - verbs[0] = MAKE_VERB(cad,nid,VID_GET_PARAM,PID_FUNCGRP_TYPE); - - if ((rc=hda_send_verbs(codec, verbs, &resp, 1)) != B_OK) + verbs[0] = MAKE_VERB(cad, nid, VID_GET_PARAM, PID_FUNCGRP_TYPE); + + if (hda_send_verbs(codec, verbs, &resp, 1) != B_OK) goto cmd_failed; - if ((resp&0xFF) == 1) { + if ((resp & 0xFF) == 1) { /* Found an Audio Function Group! */ - if ((rc=hda_codec_afg_new(codec, nid)) != B_OK) { + status_t rc = hda_codec_afg_new(codec, nid); + if (rc != B_OK) { dprintf("%s: Failed to setup new audio function group (%s)!\n", __func__, strerror(rc)); goto cmd_failed; @@ -531,7 +611,7 @@ goto exit_new; cmd_failed: - ctrlr->codecs[cad] = NULL; + controller->codecs[cad] = NULL; hda_codec_delete(codec); codec = NULL; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h 2008-02-05 09:23:05 UTC (rev 23871) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h 2008-02-05 11:21:07 UTC (rev 23872) @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar Adema, ithamar AT unet DOT nl + */ #ifndef HDA_CODEC_H #define HDA_CODEC_H Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.c 2008-02-05 09:23:05 UTC (rev 23871) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.c 2008-02-05 11:21:07 UTC (rev 23872) @@ -1,3 +1,12 @@ +/* + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: [... truncated: 1426 lines follow ...] From marcusoverhagen at arcor.de Tue Feb 5 13:16:44 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Tue, 5 Feb 2008 13:16:44 +0100 (CET) Subject: [Haiku-commits] r23872 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda Message-ID: <15295711.1202213804258.JavaMail.ngmail@webmail19> axeld at BerliOS wrote: > + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. > + * Distributed under the terms of the MIT License. > + * > + * Authors: > + * Ithamar Adema, ithamar AT unet DOT nl I don't know if we are allowed to add this. Files without license statements are a problem. By default, with no copyright and license statement on a work we have no right to use the work. So adding a license to each file is required. But only the copyright owner (Ithamar) can transfer copyright to Haiku Inc AFAIK. > - if (resp[1] & (1 << 0)) *rates |= B_SR_8000; > - if (resp[1] & (1 << 1)) *rates |= B_SR_11025; > - if (resp[1] & (1 << 2)) *rates |= B_SR_16000; [...] > + if (resp[1] & (1 << 0)) > + *rates |= B_SR_8000; > + if (resp[1] & (1 << 1)) > + *rates |= B_SR_11025; [...] > - if (resp[0] & (1 << 9)) off += sprintf(buf+off, "[Digital] "); > - if (resp[0] & (1 << 7)) off += sprintf(buf+off, "[Unsol Capable] "); > - if (resp[0] & (1 << 6)) off += sprintf(buf+off, "[Proc Widget] "); [...] > + if (resp[0] & (1 << 9)) > + off += sprintf(buf + off, "[Digital] "); Shouldn't we ignore or adapt the style guide for these cases? The original code looks much nicer in my opinion. regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From superstippi at gmx.de Tue Feb 5 13:27:50 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 05 Feb 2008 13:27:50 +0100 Subject: [Haiku-commits] r23872 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <15295711.1202213804258.JavaMail.ngmail@webmail19> References: <15295711.1202213804258.JavaMail.ngmail@webmail19> Message-ID: <20080205132750.23597.1@stippis2.1202213384.fake> Marcus Overhagen wrote (2008-02-05, 13:16:44 [+0100]): > > - if (resp[1] & (1 << 0)) *rates |= B_SR_8000; > > - if (resp[1] & (1 << 1)) *rates |= B_SR_11025; > > - if (resp[1] & (1 << 2)) *rates |= B_SR_16000; > [...] > > + if (resp[1] & (1 << 0)) > > + *rates |= B_SR_8000; > > + if (resp[1] & (1 << 1)) > > + *rates |= B_SR_11025; > [...] > > - if (resp[0] & (1 << 9)) off += sprintf(buf+off, "[Digital] > > "); > > - if (resp[0] & (1 << 7)) off += sprintf(buf+off, "[Unsol > > Capable] "); > > - if (resp[0] & (1 << 6)) off += sprintf(buf+off, "[Proc > > Widget] "); > [...] > > + if (resp[0] & (1 << 9)) > > + off += sprintf(buf + off, "[Digital] "); > > Shouldn't we ignore or adapt the style guide for these cases? The > original code looks much nicer in my opinion. I tend to agree. :-) Though I would restrict this option to when the code forms such a repititive block like above. Best regards, -Stephan From axeld at mail.berlios.de Tue Feb 5 13:36:19 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Feb 2008 13:36:19 +0100 Subject: [Haiku-commits] r23873 - haiku/trunk/build/jam Message-ID: <200802051236.m15CaJcF012634@sheep.berlios.de> Author: axeld Date: 2008-02-05 13:36:18 +0100 (Tue, 05 Feb 2008) New Revision: 23873 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23873&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/NetBootArchive Log: * intel is x86 only. * NetBootArchive still used "agp"; replaced it with agp_gart, and added the Intel GART module as well. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-05 11:21:07 UTC (rev 23872) +++ haiku/trunk/build/jam/HaikuImage 2008-02-05 12:36:18 UTC (rev 23873) @@ -135,7 +135,7 @@ AddFilesToHaikuImage beos system add-ons kernel bus_managers : $(BEOS_ADD_ONS_BUS_MANAGERS) ; AddFilesToHaikuImage beos system add-ons kernel busses agp_gart - : intel ; + : $(X86_ONLY)intel ; AddFilesToHaikuImage beos system add-ons kernel busses ide : generic_ide_pci $(X86_ONLY)ide_isa silicon_image_3112 legacy_sata ; AddFilesToHaikuImage beos system add-ons kernel busses scsi Modified: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2008-02-05 11:21:07 UTC (rev 23872) +++ haiku/trunk/build/jam/NetBootArchive 2008-02-05 12:36:18 UTC (rev 23873) @@ -25,7 +25,7 @@ $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)isa ide scsi - config_manager $(X86_ONLY)agp + config_manager agp_gart ; BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda fat googlefs iso9660 nfs ; @@ -33,6 +33,8 @@ # modules AddFilesToNetBootArchive beos system add-ons kernel bus_managers : $(BEOS_ADD_ONS_BUS_MANAGERS) ; +AddFilesToNetBootArchive beos system add-ons kernel busses agp_gart + : $(X86_ONLY)intel ; AddFilesToNetBootArchive beos system add-ons kernel busses ide : ahci generic_ide_pci $(X86_ONLY)ide_isa silicon_image_3112 ; AddFilesToNetBootArchive beos system add-ons kernel console : vga_text ; From axeld at pinc-software.de Tue Feb 5 14:00:14 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 05 Feb 2008 14:00:14 +0100 CET Subject: [Haiku-commits] r23872 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <15295711.1202213804258.JavaMail.ngmail@webmail19> Message-ID: <13108964530-BeMail@zon> Marcus Overhagen wrote: > axeld at BerliOS wrote: > > + * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. > > + * Distributed under the terms of the MIT License. > > + * > > + * Authors: > > + * Ithamar Adema, ithamar AT unet DOT nl > I don't know if we are allowed to add this. > > Files without license statements are a problem. By default, > with no copyright and license statement on a work we have > no right to use the work. So adding a license to each file > is required. But only the copyright owner (Ithamar) can > transfer copyright to Haiku Inc AFAIK. If someone specifically writes code for Haiku, and puts that in our repository, I think we can assume this copyright notice is in fact okay. If not, Ithamar can easily veto :-) > > - if (resp[1] & (1 << 0)) *rates |= B_SR_8000; > > - if (resp[1] & (1 << 1)) *rates |= B_SR_11025; > > - if (resp[1] & (1 << 2)) *rates |= B_SR_16000; > [...] > > + if (resp[1] & (1 << 0)) > > + *rates |= B_SR_8000; > > + if (resp[1] & (1 << 1)) > > + *rates |= B_SR_11025; > Shouldn't we ignore or adapt the style guide for these cases? > The original code looks much nicer in my opinion. Ah well, I dunno; I don't really mind that much, I just usually dislike to use tabs this way. Even though, the examples above are probably better off using a different method, anyway (like an array with a computed index). Bye, Axel. From stippi at mail.berlios.de Tue Feb 5 16:13:14 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 16:13:14 +0100 Subject: [Haiku-commits] r23874 - haiku/trunk/src/add-ons/kernel/partitioning_systems/intel Message-ID: <200802051513.m15FDEj0009814@sheep.berlios.de> Author: stippi Date: 2008-02-05 16:13:14 +0100 (Tue, 05 Feb 2008) New Revision: 23874 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23874&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp Log: Spotted a leak while trying to understand what's happening. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp 2008-02-05 12:36:18 UTC (rev 23873) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/write_support.cpp 2008-02-05 15:13:14 UTC (rev 23874) @@ -2027,8 +2027,10 @@ update_disk_device_job_progress(job, 0.0); partition_data *child = create_child_partition(partition->id, index, *childID); - if (!child) + if (!child) { + delete logical; return B_ERROR; + } PartitionType ptype; ptype.SetType(type); From stippi at mail.berlios.de Tue Feb 5 16:16:22 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 16:16:22 +0100 Subject: [Haiku-commits] r23875 - haiku/trunk/src/kits/storage/disk_device Message-ID: <200802051516.m15FGMDs010680@sheep.berlios.de> Author: stippi Date: 2008-02-05 16:16:22 +0100 (Tue, 05 Feb 2008) New Revision: 23875 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23875&view=rev Modified: haiku/trunk/src/kits/storage/disk_device/Partition.cpp Log: IMHO these are a little better error codes. If fDelegate is NULL, it means the BDiskDevice of a BPartiton has not been prepared for modifications. To me, it means the initialization status of the object does not support the operation, hence B_NO_INIT. B_BAD_DATA hints to me that I have passed invalid data to a function. Modified: haiku/trunk/src/kits/storage/disk_device/Partition.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2008-02-05 15:13:14 UTC (rev 23874) +++ haiku/trunk/src/kits/storage/disk_device/Partition.cpp 2008-02-05 15:16:22 UTC (rev 23875) @@ -640,8 +640,10 @@ status_t BPartition::GetPartitioningInfo(BPartitioningInfo* info) const { - if (!fDelegate || !info) + if (!info) return B_BAD_VALUE; + if (!fDelegate) + return B_NO_INIT; return fDelegate->GetPartitioningInfo(info); } @@ -686,7 +688,7 @@ BPartition::Defragment() const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->Defragment(); } @@ -715,7 +717,7 @@ BPartition::Repair(bool checkOnly) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->Repair(checkOnly); } @@ -748,7 +750,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; status_t error = parent->fDelegate->ValidateResizeChild(fDelegate, size); if (error != B_OK) @@ -775,7 +777,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; status_t error; off_t contentSize = size; @@ -850,7 +852,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; status_t error = parent->fDelegate->ValidateMoveChild(fDelegate, offset); if (error != B_OK) @@ -876,7 +878,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; status_t error = parent->fDelegate->MoveChild(fDelegate, offset); if (error != B_OK) @@ -911,7 +913,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->ValidateSetName(fDelegate, name); } @@ -923,7 +925,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->SetName(fDelegate, name); } @@ -944,7 +946,7 @@ BPartition::ValidateSetContentName(BString* name) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->ValidateSetContentName(name); } @@ -955,7 +957,7 @@ BPartition::SetContentName(const char* name) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->SetContentName(name); } @@ -980,7 +982,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->ValidateSetType(fDelegate, type); } @@ -992,7 +994,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->SetType(fDelegate, type); } @@ -1017,7 +1019,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->GetParameterEditor(fDelegate, editor); } @@ -1029,7 +1031,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return parent->fDelegate->SetParameters(fDelegate, parameters); } @@ -1050,7 +1052,7 @@ BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor** editor) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->GetContentParameterEditor(editor); } @@ -1061,7 +1063,7 @@ BPartition::SetContentParameters(const char* parameters) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->SetContentParameters(parameters); } @@ -1073,7 +1075,7 @@ { BPartition* parent = Parent(); if (!parent || !fDelegate) - return false; + return B_NO_INIT; return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie, type); @@ -1085,7 +1087,7 @@ BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->GetNextSupportedChildType(NULL, cookie, type); } @@ -1117,7 +1119,7 @@ BDiskDeviceParameterEditor** editor) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->GetInitializationParameterEditor(diskSystem, editor); } @@ -1129,7 +1131,7 @@ const char* parameters) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->ValidateInitialize(diskSystem, name, parameters); } @@ -1141,7 +1143,7 @@ const char* parameters) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->Initialize(diskSystem, name, parameters); } @@ -1152,7 +1154,7 @@ BPartition::Uninitialize() { // TODO: Implement! - return B_BAD_VALUE; + return B_NOT_SUPPORTED; } @@ -1170,7 +1172,7 @@ BDiskDeviceParameterEditor** editor) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->GetChildCreationParameterEditor(type, editor); } @@ -1182,7 +1184,7 @@ BString* name, const char* parameters) const { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->ValidateCreateChild(offset, size, type, name, parameters); } @@ -1194,7 +1196,7 @@ const char* name, const char* parameters, BPartition** child) { if (!fDelegate) - return B_BAD_VALUE; + return B_NO_INIT; return fDelegate->CreateChild(offset, size, type, name, parameters, child); } @@ -1217,8 +1219,10 @@ status_t BPartition::DeleteChild(int32 index) { + if (!fDelegate) + return B_NO_INIT; BPartition* child = ChildAt(index); - if (!fDelegate || !child || child->Parent() != this) + if (!child || child->Parent() != this) return B_BAD_VALUE; return fDelegate->DeleteChild(child->fDelegate); @@ -1525,7 +1529,7 @@ BPartition::_CreateDelegates() { if (fDelegate || !fPartitionData) - return B_BAD_VALUE; + return B_NO_INIT; // create and init delegate fDelegate = new(nothrow) Delegate(this); From stippi at mail.berlios.de Tue Feb 5 16:23:19 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 16:23:19 +0100 Subject: [Haiku-commits] r23876 - haiku/trunk/src/add-ons/disk_systems/intel Message-ID: <200802051523.m15FNJex011699@sheep.berlios.de> Author: stippi Date: 2008-02-05 16:23:19 +0100 (Tue, 05 Feb 2008) New Revision: 23876 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23876&view=rev Modified: haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.h Log: I took the liberty of implementing GetNextSupportedType(), which is needed to be able to call BPartition::GetNextSupportedChildType(). For the PartitionMapAddOn, the types should be either primary or extended, depending on the number of empty primary partitions and the existance of one extended partition. DriveSetup shows "Intel Primary Partition" and "Intel Extended Partition" in the Create menu now. Ingo, please review, maybe I didn't understand the plan correctly. Also, I tried to follow the code path, which is quite nested, and am pretty confused.. For example, I didn't find the place where the CreateChildJob is finally created. Is this missing yet? Modified: haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp 2008-02-05 15:16:22 UTC (rev 23875) +++ haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp 2008-02-05 15:23:19 UTC (rev 23876) @@ -245,6 +245,66 @@ } +// GetNextSupportedType +status_t +PartitionMapHandle::GetNextSupportedType(const BMutablePartition* child, + int32* cookie, BString* type) +{ + // TODO: What are we supposed to do with the child? + + // we support creating two types, primary and extended + if (*cookie < 0 || *cookie > 1) + return B_ENTRY_NOT_FOUND; + + // check if there are any spaces at all + // TODO: check if the spaces have enough size at all + BPartitioningInfo info; + status_t ret = GetPartitioningInfo(&info); + if (ret < B_OK) + return ret; + + if (info.CountPartitionableSpaces() == 0) + return B_ENTRY_NOT_FOUND; + + // adjust the cookie here already so that we don't have + // to worry about it when returning early below + *cookie = *cookie + 1; + + if (*cookie == 1) { + // On first iteration, check if we can create more primary + // partitions. If this is not possible, we cannot create + // any extended partitions either. + for (int32 i = 0; i < 4; i++) { + PrimaryPartition* primary = fPartitionMap.PrimaryPartitionAt(i); + if (primary->IsEmpty()) { + *type = kPartitionTypeIntelPrimary; + return B_OK; + } + } + } else if (*cookie == 2) { + // On second iteration, check if we can create more primary + // partitions. Also check if there already is an extended + // partition, only if there is at least one empty and no + // extended partition, we can create an extended partition. + bool foundExtended = false; + bool foundEmpty = false; + for (int32 i = 0; i < 4; i++) { + PrimaryPartition* primary = fPartitionMap.PrimaryPartitionAt(i); + if (primary->IsEmpty()) + foundEmpty = true; + else if (primary->IsExtended()) + foundExtended = true; + } + if (foundEmpty && !foundExtended) { + *type = kPartitionTypeIntelExtended; + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + // GetPartitioningInfo status_t PartitionMapHandle::GetPartitioningInfo(BPartitioningInfo* info) Modified: haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.h =================================================================== --- haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.h 2008-02-05 15:16:22 UTC (rev 23875) +++ haiku/trunk/src/add-ons/disk_systems/intel/PartitionMapAddOn.h 2008-02-05 15:23:19 UTC (rev 23876) @@ -46,6 +46,10 @@ const BMutablePartition* child, uint32 mask); + virtual status_t GetNextSupportedType( + const BMutablePartition* child, + int32* cookie, BString* type); + virtual status_t GetPartitioningInfo(BPartitioningInfo* info); virtual status_t GetChildCreationParameterEditor( From stippi at mail.berlios.de Tue Feb 5 18:57:41 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 5 Feb 2008 18:57:41 +0100 Subject: [Haiku-commits] r23877 - haiku/trunk/src/add-ons/disk_systems/intel Message-ID: <200802051757.m15HvfQx007185@sheep.berlios.de> Author: stippi Date: 2008-02-05 18:57:40 +0100 (Tue, 05 Feb 2008) New Revision: 23877 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23877&view=rev Modified: haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h Log: I tried to follow the example of PartitionMapAddOn and implemented more stuff for the ExtendedPartitionAddOn. If I understand correctly, from the point of view of the Disk Device API, ExtendedPartitionAddOn is a disk system which supports child partitions and is analogous to PartitionMapAddOn. The type string for the supported child partitions is probably wrong, since I used "Intel Logical Partition".... In fact, the types currently returned by PartitionMapAddOn are not as intended either. We will have to think of how we want this particular feature to work. Modified: haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp 2008-02-05 15:23:19 UTC (rev 23876) +++ haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.cpp 2008-02-05 17:57:40 UTC (rev 23877) @@ -9,17 +9,42 @@ #include #include +#include +#include + using std::nothrow; +static const uint32 kDiskSystemFlags = + 0 +// | B_DISK_SYSTEM_SUPPORTS_CHECKING +// | B_DISK_SYSTEM_SUPPORTS_REPAIRING +// | B_DISK_SYSTEM_SUPPORTS_RESIZING +// | B_DISK_SYSTEM_SUPPORTS_MOVING +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME +// | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS + | B_DISK_SYSTEM_SUPPORTS_INITIALIZING +// | B_DISK_SYSTEM_SUPPORTS_CONTENT_NAME + +// | B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD +// | B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD +// | B_DISK_SYSTEM_SUPPORTS_SETTING_NAME + | B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE +// | B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS + | B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD + | B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD +// | B_DISK_SYSTEM_SUPPORTS_NAME +; + + // #pragma mark - ExtendedPartitionAddOn // constructor ExtendedPartitionAddOn::ExtendedPartitionAddOn() - : BDiskSystemAddOn(kPartitionTypeIntelExtended, 0) + : BDiskSystemAddOn(kPartitionTypeIntelExtended, kDiskSystemFlags) { } @@ -51,6 +76,79 @@ } +// CanInitialize +bool +ExtendedPartitionAddOn::CanInitialize(const BMutablePartition* partition) +{ + // If it's big enough, we can initialize it. + return partition->Size() >= 2 * SECTOR_SIZE; +} + + +// GetInitializationParameterEditor +status_t +ExtendedPartitionAddOn::GetInitializationParameterEditor( + const BMutablePartition* partition, BDiskDeviceParameterEditor** editor) +{ + // Nothing to edit, really. + *editor = NULL; + return B_OK; +} + + +// ValidateInitialize +status_t +ExtendedPartitionAddOn::ValidateInitialize(const BMutablePartition* partition, + BString* name, const char* parameters) +{ + if (!CanInitialize(partition) + || parameters != NULL && strlen(parameters) > 0) { + return B_BAD_VALUE; + } + + // we don't support a content name + if (name != NULL) + name->Truncate(0); + + return B_OK; +} + + +// Initialize +status_t +ExtendedPartitionAddOn::Initialize(BMutablePartition* partition, + const char* name, const char* parameters, BPartitionHandle** _handle) +{ + if (!CanInitialize(partition) + || name != NULL && strlen(name) > 0 + || parameters != NULL && strlen(parameters) > 0) { + return B_BAD_VALUE; + } + + // create the handle + ExtendedPartitionHandle* handle + = new(nothrow) ExtendedPartitionHandle(partition); + if (!handle) + return B_NO_MEMORY; + ObjectDeleter handleDeleter(handle); + + // init the partition + status_t error = partition->SetContentType(Name()); + if (error != B_OK) + return error; +// TODO: The content type could as well be set by the caller. + + partition->SetContentName(NULL); + partition->SetContentParameters(NULL); + partition->SetBlockSize(SECTOR_SIZE); + partition->SetContentSize(partition->Size() / SECTOR_SIZE * SECTOR_SIZE); + + *_handle = handleDeleter.Detach(); + + return B_OK; +} + + // #pragma mark - ExtendedPartitionHandle @@ -107,3 +205,281 @@ return B_OK; } + + +// SupportedOperations +uint32 +ExtendedPartitionHandle::SupportedOperations(uint32 mask) +{ + uint32 flags = B_DISK_SYSTEM_SUPPORTS_INITIALIZING; + + // creating child + if (mask & B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD) { + BPartitioningInfo info; + if (GetPartitioningInfo(&info) == B_OK + && info.CountPartitionableSpaces() > 1) { + flags |= B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD; + } + } + + return flags; +} + + +// SupportedChildOperations +uint32 +ExtendedPartitionHandle::SupportedChildOperations( + const BMutablePartition* child, uint32 mask) +{ + return B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD; +} + + +// GetNextSupportedType +status_t +ExtendedPartitionHandle::GetNextSupportedType(const BMutablePartition* child, + int32* cookie, BString* type) +{ + if (*cookie != 0) + return B_ENTRY_NOT_FOUND; + *cookie = *cookie + 1; + *type = kPartitionTypeIntelLogical; + return B_OK; +} + + +// GetPartitioningInfo +status_t +ExtendedPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info) +{ + // NOTE stippi: At first I tried to use the fPrimaryPartition + // here but it does not return any LogicalPartitions. What + // happens now is probably what used to happen before, though + // I don't understand *where*, since this handle type never + // implemented this virtual function. + + // init to the full size (minus the first sector) + BMutablePartition* partition = Partition(); + off_t offset = partition->Offset();// + SECTOR_SIZE; + off_t size = partition->Size();//- SECTOR_SIZE; + status_t error = info->SetTo(offset, size); + if (error != B_OK) + return error; + + // exclude the space of the existing logical partitions + int32 count = partition->CountChildren(); +printf("%ld logical partitions\n", count); + for (int32 i = 0; i < count; i++) { + BMutablePartition* child = partition->ChildAt(i); + // TODO: Does this correctly account for the partition table + // sectors? Preceeding each logical partition should be a + // sector for the partition table entry. Those entries form + // the linked list of "inner extended partition" + "real partition" + // Following the logic above (copied from PartitionMapAddOn), + // the outer size includes the first sector and is therefor + // what we need here. + error = info->ExcludeOccupiedSpace(child->Offset(), child->Size()); +printf(" %ld: offset = %lld (relative: %lld), size = %lld\n", i, +child->Offset(), child->Offset() - offset, child->Size()); + if (error != B_OK) + return error; + } +info->PrintToStream(); + + return B_OK; +} + + +// GetChildCreationParameterEditor +status_t +ExtendedPartitionHandle::GetChildCreationParameterEditor(const char* type, + BDiskDeviceParameterEditor** editor) +{ + // TODO: We actually need an editor here. + *editor = NULL; + return B_OK; +} + + +// ValidateCreateChild +status_t +ExtendedPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size, + const char* typeString, BString* name, const char* parameters) +{ + // check type + if (!typeString || strcmp(typeString, kPartitionTypeIntelLogical) != 0) + return B_BAD_VALUE; + + // check name + if (name) + name->Truncate(0); + + // check parameters + // TODO:... + +return B_NOT_SUPPORTED; +// // check the free space situation +// BPartitioningInfo info; +// status_t error = GetPartitioningInfo(&info); +// if (error != B_OK) +// return error; +// +// // any space in the partition at all? +// int32 spacesCount = info.CountPartitionableSpaces(); +// if (spacesCount == 0) +// return B_BAD_VALUE; +// +// // check offset and size +// off_t offset = sector_align(*_offset); +// off_t size = sector_align(*_size); +// // TODO: Rather round size up? +// off_t end = offset + size; +// +// // get the first partitionable space the requested interval intersects with +// int32 spaceIndex = -1; +// int32 closestSpaceIndex = -1; +// off_t closestSpaceDistance = 0; +// for (int32 i = 0; i < spacesCount; i++) { +// off_t spaceOffset, spaceSize; +// info.GetPartitionableSpaceAt(i, &spaceOffset, &spaceSize); +// off_t spaceEnd = spaceOffset + spaceSize; +// +// if (spaceOffset >= offset && spaceOffset < end +// || offset >= spaceOffset && offset < spaceEnd) { +// spaceIndex = i; +// break; +// } +// +// off_t distance; +// if (offset < spaceOffset) +// distance = spaceOffset - end; +// else +// distance = spaceEnd - offset; +// +// if (closestSpaceIndex == -1 || distance < closestSpaceDistance) { +// closestSpaceIndex = i; +// closestSpaceDistance = distance; +// } +// } +// +// // get the space we found +// off_t spaceOffset, spaceSize; +// info.GetPartitionableSpaceAt( +// spaceIndex >= 0 ? spaceIndex : closestSpaceIndex, &spaceOffset, +// &spaceSize); +// off_t spaceEnd = spaceOffset + spaceSize; +// +// // If the requested intervald doesn't intersect with any space yet, move +// // it, so that it does. +// if (spaceIndex < 0) { +// spaceIndex = closestSpaceIndex; +// if (offset < spaceOffset) { +// offset = spaceOffset; +// end = offset + size; +// } else { +// end = spaceEnd; +// offset = end - size; +// } +// } +// +// // move/shrink the interval, so that it fully lies within the space +// if (offset < spaceOffset) { +// offset = spaceOffset; +// end = offset + size; +// if (end > spaceEnd) { +// end = spaceEnd; +// size = end - offset; +// } +// } else if (end > spaceEnd) { +// end = spaceEnd; +// offset = end - size; +// if (offset < spaceOffset) { +// offset = spaceOffset; +// size = end - offset; +// } +// } +// +// *_offset = offset; +// *_size = size; +// +// return B_OK; +} + + +// CreateChild +status_t +ExtendedPartitionHandle::CreateChild(off_t offset, off_t size, + const char* typeString, const char* name, const char* parameters, + BMutablePartition** _child) +{ + // check type + if (!typeString || strcmp(typeString, kPartitionTypeIntelLogical) != 0) + return B_BAD_VALUE; + + // check name + if (name && strlen(name) > 0) + return B_BAD_VALUE; + + // check parameters + // TODO:... + +return B_NOT_SUPPORTED; +// // offset properly aligned? +// if (offset != sector_align(offset) || size != sector_align(size)) +// return B_BAD_VALUE; +// +// // check the free space situation +// BPartitioningInfo info; +// status_t error = GetPartitioningInfo(&info); +// if (error != B_OK) +// return error; +// +// bool foundSpace = false; +// off_t end = offset + size; +// int32 spacesCount = info.CountPartitionableSpaces(); +// for (int32 i = 0; i < spacesCount; i++) { +// off_t spaceOffset, spaceSize; +// info.GetPartitionableSpaceAt(i, &spaceOffset, &spaceSize); +// off_t spaceEnd = spaceOffset + spaceSize; +// +// if (offset >= spaceOffset && end <= spaceEnd) { +// foundSpace = true; +// break; +// } +// } +// +// if (!foundSpace) +// return B_BAD_VALUE; +// +// // everything looks good, do it +// +// // create the child +// // (Note: the primary partition index is indeed the child index, since +// // we picked the first empty primary partition.) +// BMutablePartition* partition = Partition(); +// BMutablePartition* child; +// error = partition->CreateChild(primary->Index(), typeString, NULL, +// parameters, &child); +// if (error != B_OK) +// return error; +// +// // init the child +// child->SetOffset(offset); +// child->SetSize(size); +// child->SetBlockSize(SECTOR_SIZE); +// //child->SetFlags(0); +// child->SetChildCookie(primary); +// +// // init the primary partition +// bool active = false; +// // TODO: Get from parameters! +// primary->SetTo(offset, size, type.Type(), active); +// +//// TODO: If the child is an extended partition, we should trigger its +//// initialization. +// +// *_child = child; +// return B_OK; +} + + Modified: haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h =================================================================== --- haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h 2008-02-05 15:23:19 UTC (rev 23876) +++ haiku/trunk/src/add-ons/disk_systems/intel/ExtendedPartitionAddOn.h 2008-02-05 17:57:40 UTC (rev 23877) @@ -19,6 +19,17 @@ BMutablePartition* partition, BPartitionHandle** handle); + virtual bool CanInitialize( + const BMutablePartition* partition); + virtual status_t GetInitializationParameterEditor( + const BMutablePartition* partition, + BDiskDeviceParameterEditor** editor); + virtual status_t ValidateInitialize( + const BMutablePartition* partition, + BString* name, const char* parameters); + virtual status_t Initialize(BMutablePartition* partition, + const char* name, const char* parameters, + BPartitionHandle** handle); }; @@ -30,6 +41,27 @@ status_t Init(); + virtual uint32 SupportedOperations(uint32 mask); + virtual uint32 SupportedChildOperations( + const BMutablePartition* child, + uint32 mask); + + virtual status_t GetNextSupportedType( + const BMutablePartition* child, + int32* cookie, BString* type); + + virtual status_t GetPartitioningInfo(BPartitioningInfo* info); + + virtual status_t GetChildCreationParameterEditor( + const char* type, + BDiskDeviceParameterEditor** editor); + virtual status_t ValidateCreateChild(off_t* offset, + off_t* size, const char* type, + BString* name, const char* parameters); + virtual status_t CreateChild(off_t offset, off_t size, + const char* type, const char* name, + const char* parameters, + BMutablePartition** child); private: PrimaryPartition* fPrimaryPartition; }; From bonefish at mail.berlios.de Tue Feb 5 20:40:27 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 5 Feb 2008 20:40:27 +0100 Subject: [Haiku-commits] r23878 - haiku/trunk/src/build/libroot Message-ID: <200802051940.m15JeRtB029594@sheep.berlios.de> Author: bonefish Date: 2008-02-05 20:40:26 +0100 (Tue, 05 Feb 2008) New Revision: 23878 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23878&view=rev Modified: haiku/trunk/src/build/libroot/fs.cpp Log: Converted to UNIX line breaks. Modified: haiku/trunk/src/build/libroot/fs.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs.cpp 2008-02-05 17:57:40 UTC (rev 23877) +++ haiku/trunk/src/build/libroot/fs.cpp 2008-02-05 19:40:26 UTC (rev 23878) @@ -1,999 +1,999 @@ - -#include - -#include "fs_impl.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include // for B_STAT_* flags -#include - -#include "fs_descriptors.h" -#include "NodeRef.h" - -using namespace std; -using namespace BPrivate; - - -static status_t get_path(dev_t device, ino_t node, const char *name, - string &path); - - -// find_dir_entry -static status_t -find_dir_entry(DIR *dir, const char *path, NodeRef ref, string &name, - bool skipDot) -{ - // find the entry - bool found = false; - while (dirent *entry = readdir(dir)) { - if ((!skipDot && strcmp(entry->d_name, ".") == 0) - || strcmp(entry->d_name, "..") == 0) { - // skip "." and ".." - } else /*if (entry->d_ino == ref.node)*/ { - // Note: Linux doesn't seem to translate dirent::d_ino of - // mount points. Thus we always have to lstat(). - // We also need to compare the device, which is generally not - // included in the dirent structure. Hence we lstat(). - string entryPath(path); - entryPath += '/'; - entryPath += entry->d_name; - struct stat st; - if (lstat(entryPath.c_str(), &st) == 0) { - if (NodeRef(st) == ref) { - name = entry->d_name; - found = true; - break; - } - } - } - } - - if (!found) - return B_ENTRY_NOT_FOUND; - - return B_OK; -} - -// find_dir_entry -static status_t -find_dir_entry(const char *path, NodeRef ref, string &name, bool skipDot) -{ - // open dir - DIR *dir = opendir(path); - if (!dir) - return errno; - - status_t error = find_dir_entry(dir, path, ref, name, skipDot); - - // close dir - closedir(dir); - - return error; -} - -// normalize_dir_path -static status_t -normalize_dir_path(string path, NodeRef ref, string &normalizedPath) -{ - // get parent path - path += "/.."; - - // stat the parent dir - struct stat st; - if (lstat(path.c_str(), &st) < 0) - return errno; - - // root dir? - NodeRef parentRef(st); - if (parentRef == ref) { - normalizedPath = "/"; - return 0; - } - - // find the entry - string name; - status_t error = find_dir_entry(path.c_str(), ref, name, true) ; - if (error != B_OK) - return error; - - // recurse to get the parent dir path, if found - error = normalize_dir_path(path, parentRef, normalizedPath); - if (error != 0) - return error; - - // construct the normalizedPath - if (normalizedPath.length() > 1) // don't append "/", if parent is root - normalizedPath += '/'; - normalizedPath += name; - - return 0; -} - -// normalize_dir_path -static status_t -normalize_dir_path(const char *path, string &normalizedPath) -{ - // stat() the dir - struct stat st; - if (stat(path, &st) < 0) - return errno; - - return normalize_dir_path(path, NodeRef(st), normalizedPath); -} - -// normalize_entry_path -static status_t -normalize_entry_path(const char *path, string &normalizedPath) -{ - const char *dirPath = NULL; - const char *leafName = NULL; - - string dirPathString; - if (char *lastSlash = strrchr(path, '/')) { - // found a slash: decompose into dir path and leaf name - leafName = lastSlash + 1; - if (leafName[0] == '\0') { - // slash is at the end: the whole path is a dir name - leafName = NULL; - } else { - dirPathString = string(path, leafName - path); - dirPath = dirPathString.c_str(); - } - - } else { - // path contains no slash, so it is a path relative to the current dir - dirPath = "."; - leafName = path; - } - - // catch special case: no leaf, or leaf is a directory - if (!leafName || strcmp(leafName, ".") == 0 || strcmp(leafName, "..") == 0) - return normalize_dir_path(path, normalizedPath); - - // normalize the dir path - status_t error = normalize_dir_path(dirPath, normalizedPath); - if (error != B_OK) - return error; - - // append the leaf name - if (normalizedPath.length() > 1) // don't append "/", if parent is root - normalizedPath += '/'; - normalizedPath += leafName; - - return B_OK; -} - - -// #pragma mark - - -typedef map DirPathMap; -static DirPathMap sDirPathMap; - -// get_path -static status_t -get_path(const NodeRef *ref, const char *name, string &path) -{ - if (!ref && !name) - return B_BAD_VALUE; - - // no ref or absolute path - if (!ref || (name && name[0] == '/')) { - path = name; - return B_OK; - } - - // get the dir path - if (ref) { - DirPathMap::iterator it = sDirPathMap.find(*ref); - if (it == sDirPathMap.end()) - return B_ENTRY_NOT_FOUND; - - path = it->second; - - // stat the path to check, if it is still valid - struct stat st; - if (lstat(path.c_str(), &st) < 0) { - sDirPathMap.erase(it); - return errno; - } - - // compare the NodeRef - if (NodeRef(st) != *ref) { - sDirPathMap.erase(it); - return B_ENTRY_NOT_FOUND; - } - - // still a directory? - if (!S_ISDIR(st.st_mode)) { - sDirPathMap.erase(it); - return B_NOT_A_DIRECTORY; - } - } - - // if there's a name, append it - if (name) { - path += '/'; - path += name; - } - - return B_OK; -} - -// get_path -status_t -BPrivate::get_path(int fd, const char *name, string &path) -{ - // get the node ref for the fd, if any, and the path part is not absolute - if (fd >= 0 && !(name && name[0] == '/')) { - // get descriptor - Descriptor *descriptor = get_descriptor(fd); - if (!descriptor) - return B_FILE_ERROR; - - // get node ref for the descriptor - NodeRef ref; - status_t error = descriptor->GetNodeRef(ref); - if (error != B_OK) - return error; - - return ::get_path(&ref, name, path); - - } else // no descriptor or absolute path - return ::get_path((NodeRef*)NULL, name, path); -} - -// get_path -static status_t -get_path(dev_t device, ino_t directory, const char *name, string &path) -{ - NodeRef ref; - ref.device = device; - ref.node = directory; - - return get_path(&ref, name, path); -} - -// add_dir_path -static void -add_dir_path(const char *path, const NodeRef &ref) -{ - // add the normalized path - string normalizedPath; - if (normalize_dir_path(path, normalizedPath) == B_OK) - sDirPathMap[ref] = normalizedPath; -} - - -// #pragma mark - - -// _kern_entry_ref_to_path -status_t -_kern_entry_ref_to_path(dev_t device, ino_t node, const char *leaf, - char *userPath, size_t pathLength) -{ - // get the path - string path; - status_t error = get_path(device, node, leaf, path); - if (error != B_OK) - return error; - - // copy it back to the user buffer - if (strlcpy(userPath, path.c_str(), pathLength) >= pathLength) - return B_BUFFER_OVERFLOW; - - return B_OK; -} - - -// #pragma mark - - -// _kern_create_dir -status_t -_kern_create_dir(int fd, const char *path, int perms) -{ - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - // mkdir - if (mkdir(realPath.c_str(), perms) < 0) - return errno; - - return B_OK; -} - -// _kern_create_dir_entry_ref -status_t -_kern_create_dir_entry_ref(dev_t device, ino_t node, const char *name, - int perms) -{ - // get a usable path - string realPath; - status_t error = get_path(device, node, name, realPath); - if (error != B_OK) - return error; - - // mkdir - if (mkdir(realPath.c_str(), perms) < 0) - return errno; - - return B_OK; -} - -// open_dir -static int -open_dir(const char *path) -{ - // open the dir - DIR *dir = opendir(path); - if (!dir) - return errno; - - // stat the entry - struct stat st; - if (stat(path, &st) < 0) { - closedir(dir); - return errno; - } - - if (!S_ISDIR(st.st_mode)) { - closedir(dir); - return B_NOT_A_DIRECTORY; - } - - // cache dir path - NodeRef ref(st); - add_dir_path(path, ref); - - // create descriptor - DirectoryDescriptor *descriptor = new DirectoryDescriptor(dir, ref); - return add_descriptor(descriptor); -} - -// _kern_open_dir -int -_kern_open_dir(int fd, const char *path) -{ - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - return open_dir(realPath.c_str()); -} - -// _kern_open_dir_entry_ref -int -_kern_open_dir_entry_ref(dev_t device, ino_t node, const char *name) -{ - // get a usable path - string realPath; - status_t error = get_path(device, node, name, realPath); - if (error != B_OK) - return error; - - return open_dir(realPath.c_str()); -} - -// _kern_open_parent_dir -int -_kern_open_parent_dir(int fd, char *name, size_t nameLength) -{ - // get a usable path - string realPath; - status_t error = get_path(fd, name, realPath); - if (error != B_OK) - return error; - - // stat the entry - struct stat st; - if (stat(realPath.c_str(), &st) < 0) - return errno; - - if (!S_ISDIR(st.st_mode)) - return B_NOT_A_DIRECTORY; - - // get the entry name - realPath += "/.."; - string entryName; - error = find_dir_entry(realPath.c_str(), NodeRef(st), - entryName, false); - if (error != B_OK) - return error; - - if (strlcpy(name, entryName.c_str(), nameLength) >= nameLength) - return B_BUFFER_OVERFLOW; - - // open the parent directory - - return open_dir(realPath.c_str()); -} - -// _kern_read_dir -ssize_t -_kern_read_dir(int fd, struct dirent *buffer, size_t bufferSize, - uint32 maxCount) -{ - if (maxCount <= 0) - return B_BAD_VALUE; - - // get the descriptor - DirectoryDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // get the next entry - dirent *entry; - if (dynamic_cast(descriptor)) - entry = fs_read_attr_dir(descriptor->dir); - else - entry = readdir(descriptor->dir); - if (!entry) - return errno; - - // copy the entry - int entryLen = &entry->d_name[strlen(entry->d_name) + 1] - (char*)entry; - if (entryLen > (int)bufferSize) - return B_BUFFER_OVERFLOW; - - memcpy(buffer, entry, entryLen); - - return 1; -} - -// _kern_rewind_dir -status_t -_kern_rewind_dir(int fd) -{ - // get the descriptor - DirectoryDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // rewind - if (dynamic_cast(descriptor)) - fs_rewind_attr_dir(descriptor->dir); - else - rewinddir(descriptor->dir); - - return B_OK; -} - - -// #pragma mark - - -// open_file -static int -open_file(const char *path, int openMode, int perms) -{ - // stat the node - bool exists = true; - struct stat st; - if (lstat(path, &st) < 0) { - exists = false; - if (!(openMode & O_CREAT)) - return errno; - } - - Descriptor *descriptor; - if (exists && S_ISLNK(st.st_mode) && (openMode & O_NOTRAVERSE)) { - // a symlink not to be followed: create a special descriptor - // normalize path first - string normalizedPath; - status_t error = normalize_entry_path(path, normalizedPath); - if (error != B_OK) - return error; - - descriptor = new SymlinkDescriptor(normalizedPath.c_str()); - - } else { - // open the file - openMode &= ~O_NOTRAVERSE; - int newFD = open(path, openMode, perms); - if (newFD < 0) - return errno; - - descriptor = new FileDescriptor(newFD); - } - - // cache path, if this is a directory - if (exists && S_ISDIR(st.st_mode)) - add_dir_path(path, NodeRef(st)); - - return add_descriptor(descriptor); -} - -// _kern_open -int -_kern_open(int fd, const char *path, int openMode, int perms) -{ - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - return open_file(realPath.c_str(), openMode, perms); -} - -// _kern_open_entry_ref -int -_kern_open_entry_ref(dev_t device, ino_t node, const char *name, - int openMode, int perms) -{ - // get a usable path - string realPath; - status_t error = get_path(device, node, name, realPath); - if (error != B_OK) - return error; - - return open_file(realPath.c_str(), openMode, perms); -} - -// _kern_seek -off_t -_kern_seek(int fd, off_t pos, int seekType) -{ - // get the descriptor - FileDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // seek - off_t result = lseek(descriptor->fd, pos, seekType); - if (result < 0) - return errno; - - return result; -} - -// _kern_read -ssize_t -_kern_read(int fd, off_t pos, void *buffer, size_t bufferSize) -{ - // get the descriptor - FileDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // seek - if (pos != -1) { - off_t result = lseek(descriptor->fd, pos, SEEK_SET); - if (result < 0) - return errno; - } - - // read - ssize_t bytesRead = read(descriptor->fd, buffer, bufferSize); - if (bytesRead < 0) - return errno; - - return bytesRead; -} - -// _kern_write -ssize_t -_kern_write(int fd, off_t pos, const void *buffer, size_t bufferSize) -{ - // get the descriptor - FileDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // seek - if (pos != -1) { - off_t result = lseek(descriptor->fd, pos, SEEK_SET); - if (result < 0) - return errno; - } - - // read - ssize_t bytesWritten = write(descriptor->fd, buffer, bufferSize); - if (bytesWritten < 0) - return errno; - - return bytesWritten; -} - -// _kern_close -status_t -_kern_close(int fd) -{ - return delete_descriptor(fd); -} - -// _kern_dup -int -_kern_dup(int fd) -{ - // get the descriptor - Descriptor *descriptor = get_descriptor(fd); - if (!descriptor) - return B_FILE_ERROR; - - // clone it - Descriptor *clone; - status_t error = descriptor->Dup(clone); - if (error != B_OK) - return error; - - return add_descriptor(clone); -} - -// _kern_fsync -status_t -_kern_fsync(int fd) -{ - // get the descriptor - FileDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // sync - if (fsync(descriptor->fd) < 0) - return errno; - - return B_OK; -} - -// _kern_read_stat -status_t -_kern_read_stat(int fd, const char *path, bool traverseLink, - struct stat *st, size_t statSize) -{ - if (path) { - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - // stat - int result; - if (traverseLink) - result = stat(realPath.c_str(), st); - else - result = lstat(realPath.c_str(), st); - - if (result < 0) - return errno; - } else { - Descriptor *descriptor = get_descriptor(fd); - if (!descriptor) - return B_FILE_ERROR; - - return descriptor->GetStat(traverseLink, st); - } - - return B_OK; -} - -// _kern_write_stat -status_t -_kern_write_stat(int fd, const char *path, bool traverseLink, - const struct stat *st, size_t statSize, int statMask) -{ - // get a usable path - int realFD = -1; - string realPath; - status_t error; - bool isSymlink = false; - if (path) { - error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - // stat it to see, if it is a symlink - struct stat tmpStat; - if (lstat(realPath.c_str(), &tmpStat) < 0) - return errno; - - isSymlink = S_ISLNK(tmpStat.st_mode); - - } else { - Descriptor *descriptor = get_descriptor(fd); - if (!descriptor) - return B_FILE_ERROR; - - if (FileDescriptor *fileFD - = dynamic_cast(descriptor)) { - realFD = fileFD->fd; - - } else if (dynamic_cast(descriptor)) { - error = get_path(fd, NULL, realPath); - if (error != B_OK) - return error; - - } else if (SymlinkDescriptor *linkFD - = dynamic_cast(descriptor)) { - realPath = linkFD->path; - isSymlink = true; - - } else - return B_FILE_ERROR; - } - - // We're screwed, if the node to manipulate is a symlink. All the - // available functions traverse symlinks. - if (isSymlink && !traverseLink) - return B_ERROR; - - if (realFD >= 0) { - if (statMask & B_STAT_MODE) { - if (fchmod(realFD, st->st_mode) < 0) - return errno; - } - - if (statMask & B_STAT_UID) { - if (fchown(realFD, st->st_uid, (gid_t)-1) < 0) - return errno; - } - - if (statMask & B_STAT_GID) { - if (fchown(realFD, (uid_t)-1, st->st_gid) < 0) - return errno; - } - - if (statMask & B_STAT_SIZE) { - if (ftruncate(realFD, st->st_size) < 0) - return errno; - } - - // The timestamps can only be set via utime(), but that requires a - // path we don't have. - if (statMask & (B_STAT_ACCESS_TIME | B_STAT_MODIFICATION_TIME - | B_STAT_CREATION_TIME | B_STAT_CHANGE_TIME)) { - return B_ERROR; - } - - return 0; - - } else { - if (statMask & B_STAT_MODE) { - if (chmod(realPath.c_str(), st->st_mode) < 0) - return errno; - } - - if (statMask & B_STAT_UID) { - if (chown(realPath.c_str(), st->st_uid, (gid_t)-1) < 0) - return errno; - } - - if (statMask & B_STAT_GID) { - if (chown(realPath.c_str(), (uid_t)-1, st->st_gid) < 0) - return errno; - } - - if (statMask & B_STAT_SIZE) { - if (truncate(realPath.c_str(), st->st_size) < 0) - return errno; - } - - if (statMask & (B_STAT_ACCESS_TIME | B_STAT_MODIFICATION_TIME)) { - // Grab the previous mod and access times so we only overwrite - // the specified time and not both - struct stat oldStat; - if (~statMask & (B_STAT_ACCESS_TIME | B_STAT_MODIFICATION_TIME)) { - if (stat(realPath.c_str(), &oldStat) < 0) - return errno; - } - - utimbuf buffer; - buffer.actime = (statMask & B_STAT_ACCESS_TIME) ? st->st_atime : oldStat.st_atime; - buffer.modtime = (statMask & B_STAT_MODIFICATION_TIME) ? st->st_mtime : oldStat.st_mtime; - if (utime(realPath.c_str(), &buffer) < 0) - return errno; - } - - // not supported - if (statMask & (B_STAT_CREATION_TIME | B_STAT_CHANGE_TIME)) - return B_ERROR; - } - - return B_OK; -} - - -// #pragma mark - - -// _kern_create_symlink -status_t -_kern_create_symlink(int fd, const char *path, const char *toPath, int mode) -{ - // Note: path must not be NULL, so this will always work. - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - // symlink - if (symlink(toPath, realPath.c_str()) < 0) - return errno; - - return B_OK; -} - -// _kern_read_link -status_t -_kern_read_link(int fd, const char *path, char *buffer, size_t *_bufferSize) -{ - // get the descriptor - SymlinkDescriptor *descriptor - = dynamic_cast(get_descriptor(fd)); - if (!descriptor) - return B_FILE_ERROR; - - // readlink - ssize_t bytesRead = readlink(descriptor->path.c_str(), buffer, - *_bufferSize); - if (bytesRead < 0) - return errno; - - if (*_bufferSize > 0) { - if ((size_t)bytesRead == *_bufferSize) - bytesRead--; - - buffer[bytesRead] = '\0'; - } - - *_bufferSize = bytesRead; - - return B_OK; -} - -// _kern_unlink -status_t -_kern_unlink(int fd, const char *path) -{ - // get a usable path - string realPath; - status_t error = get_path(fd, path, realPath); - if (error != B_OK) - return error; - - // unlink - if (unlink(realPath.c_str()) < 0) - return errno; - - return B_OK; -} - -// _kern_rename -status_t -_kern_rename(int oldDir, const char *oldPath, int newDir, const char *newPath) -{ - // get usable paths - string realOldPath; - status_t error = get_path(oldDir, oldPath, realOldPath); - if (error != B_OK) - return error; - - string realNewPath; - error = get_path(newDir, newPath, realNewPath); - if (error != B_OK) - return error; - - // rename - if (rename(realOldPath.c_str(), realNewPath.c_str()) < 0) - return errno; - - return B_OK; -} - - -// #pragma mark - - -// _kern_lock_node -status_t -_kern_lock_node(int fd) -{ - return B_ERROR; -} - -// _kern_unlock_node -status_t -_kern_unlock_node(int fd) -{ - return B_ERROR; -} - - -// #pragma mark - - -// read_pos -ssize_t -read_pos(int fd, off_t pos, void *buffer, size_t bufferSize) -{ - // seek - off_t result = lseek(fd, pos, SEEK_SET); - if (result < 0) - return errno; - - // read - ssize_t bytesRead = read(fd, buffer, bufferSize); - if (bytesRead < 0) { - errno = bytesRead; - return -1; - } - - return bytesRead; -} - -// write_pos -ssize_t -write_pos(int fd, off_t pos, const void *buffer, size_t bufferSize) -{ - // seek - off_t result = lseek(fd, pos, SEEK_SET); - if (result < 0) - return errno; - - // read - ssize_t bytesWritten = write(fd, buffer, bufferSize); - if (bytesWritten < 0) { - errno = bytesWritten; - return -1; - } - - return bytesWritten; -} - -// readv_pos -ssize_t -readv_pos(int fd, off_t pos, const struct iovec *vec, size_t count) -{ - // seek - off_t result = lseek(fd, pos, SEEK_SET); - if (result < 0) - return errno; - - // read - ssize_t bytesRead = readv(fd, vec, count); - if (bytesRead < 0) { - errno = bytesRead; - return -1; - } - - return bytesRead; -} - -// writev_pos -ssize_t -writev_pos(int fd, off_t pos, const struct iovec *vec, size_t count) -{ - // seek - off_t result = lseek(fd, pos, SEEK_SET); - if (result < 0) - return errno; - - // read - ssize_t bytesWritten = writev(fd, vec, count); - if (bytesWritten < 0) { - errno = bytesWritten; - return -1; [... truncated: 1004 lines follow ...] From mmlr at mail.berlios.de Tue Feb 5 21:21:45 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 5 Feb 2008 21:21:45 +0100 Subject: [Haiku-commits] r23879 - haiku/trunk/src/system/kernel Message-ID: <200802052021.m15KLjlI032529@sheep.berlios.de> Author: mmlr Date: 2008-02-05 21:21:44 +0100 (Tue, 05 Feb 2008) New Revision: 23879 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23879&view=rev Modified: haiku/trunk/src/system/kernel/heap.c Log: * Use 0xdeadbeef as an indicator to only conditionally walk the freelist. This is not safe when already freed memory is overwritten. But since we also store the next pointer of the freelist in there, overwriting would break the freelist and cause a crash in that case. This gives a drastic performance boost when freelists grow during use and especially when opening and closing a lot of programs. * Optimize filling the freed element with 0xdeadbeef by writing 4 bytes at a time instead of using single byte writes. Works as all our bins have an element size that is a multiple of four. Put a panic in there just in case this assumption isn't met for some reason. Modified: haiku/trunk/src/system/kernel/heap.c =================================================================== --- haiku/trunk/src/system/kernel/heap.c 2008-02-05 19:40:26 UTC (rev 23878) +++ haiku/trunk/src/system/kernel/heap.c 2008-02-05 20:21:44 UTC (rev 23879) @@ -497,6 +497,11 @@ address = bins[bin_index].free_list; bins[bin_index].free_list = (void *)(*(unsigned int *)bins[bin_index].free_list); bins[bin_index].free_count--; +#if PARANOID_KFREE + // Ensure that the 0xdeadbeef is cleared so we do not walk this + // freelist if the user does not clear/use these bytes. + ((uint32 *)address)[1] = 0; +#endif } else { if (bins[bin_index].raw_count == 0) { bins[bin_index].raw_list = raw_alloc(bins[bin_index].grow_size, bin_index); @@ -599,19 +604,6 @@ if (bin->element_size <= B_PAGE_SIZE && (addr_t)address % bin->element_size != 0) panic("kfree: passed invalid pointer %p! Supposed to be in bin for esize 0x%lx\n", address, bin->element_size); -#if PARANOID_KFREE - // mark the free space as freed - { - uint32 deadbeef = 0xdeadbeef; - uint8 *dead = (uint8 *)address; - uint32 i; - - // the first 4 bytes are overwritten with the next free list pointer later - for (i = 4; i < bin->element_size; i++) - dead[i] = ((uint8 *)&deadbeef)[i % 4]; - } -#endif - for (i = 0; i < bin->element_size / B_PAGE_SIZE; i++) { if (page[i].bin_index != page[0].bin_index) panic("free(): not all pages in allocation match bin_index\n"); @@ -619,14 +611,28 @@ } #if PARANOID_KFREE - // walk the free list on this bin to make sure this address doesn't exist already - { + if (((uint32 *)address)[1] == 0xdeadbeef) { + // This block looks like it was freed already, walk the free list + // on this bin to make sure this address doesn't exist. unsigned int *temp; for (temp = bin->free_list; temp != NULL; temp = (unsigned int *)*temp) { if (temp == (unsigned int *)address) panic("free(): address %p already exists in bin free list\n", address); } } + + // mark the free space as freed + { + uint32 i; + uint32 *dead = (uint32 *)address; + + if (bin->element_size % 4 != 0) + panic("free(): didn't expect a bin element size that is not a multiple of 4\n"); + + // the first 4 bytes are overwritten with the next free list pointer later + for (i = 1; i < bin->element_size / 4; i++) + dead[i] = 0xdeadbeef; + } #endif *(unsigned int *)address = (unsigned int)bin->free_list; From bonefish at mail.berlios.de Tue Feb 5 21:54:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 5 Feb 2008 21:54:42 +0100 Subject: [Haiku-commits] r23880 - in haiku/trunk/src: bin/makebootable/platform/bios_ia32 build/libroot tools/fs_shell Message-ID: <200802052054.m15KsgCD002147@sheep.berlios.de> Author: bonefish Date: 2008-02-05 21:54:42 +0100 (Tue, 05 Feb 2008) New Revision: 23880 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23880&view=rev Added: haiku/trunk/src/build/libroot/fs_freebsd.cpp haiku/trunk/src/build/libroot/fs_freebsd.h Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp haiku/trunk/src/build/libroot/Jamfile haiku/trunk/src/build/libroot/fs.cpp haiku/trunk/src/tools/fs_shell/uio.cpp haiku/trunk/src/tools/fs_shell/unistd.cpp Log: Patch by Samuel Rodriguez Perez: Added support for writing Haiku directly onto a device under FreeBSD. I messed around with the code a little (style-fixes, some refactoring) without being able to compile or test it, so be careful... Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-02-05 20:54:42 UTC (rev 23880) @@ -19,7 +19,7 @@ #include #include -// Linux support +// Linux and FreeBSD support #ifdef HAIKU_HOST_PLATFORM_LINUX # include # include @@ -27,9 +27,17 @@ # include "PartitionMap.h" # include "PartitionMapParser.h" -#endif // HAIKU_HOST_PLATFORM_LINUX +#elif HAIKU_HOST_PLATFORM_FREEBSD +# include +# include +# include +# include +# include "PartitionMap.h" +# include "PartitionMapParser.h" +#endif + static const char *kCommandName = "makebootable"; static const int kBootCodeSize = 1024; @@ -272,13 +280,98 @@ noPartition = true; } else if (S_ISCHR(st.st_mode)) { // character special: a device or partition under BeOS - #ifndef __BEOS__ + // or under FreeBSD + #if !defined(__BEOS__) && !defined(HAIKU_HOST_PLATFORM_FREEBSD) fprintf(stderr, "Error: Character special devices not " "supported on this platform.\n"); exit(1); #endif + + #ifdef HAIKU_HOST_PLATFORM_FREEBSD + + // chop off the trailing number + int fileNameLen = strlen(fileName); + int baseNameLen = -1; + for (int k = fileNameLen - 1; k >= 0; k--) { + if (!isdigit(fileName[k])) { + baseNameLen = k + 1; + break; + } + } + + // Remove de 's' from 'ad2s2' slice device (partition for DOS + // users) to get 'ad2' base device + baseNameLen--; + + if (baseNameLen < 0) { + // only digits? + fprintf(stderr, "Error: Failed to get base device name.\n"); + exit(1); + } + + if (baseNameLen < fileNameLen) { + // get base device name and partition index + char baseDeviceName[B_PATH_NAME_LENGTH]; + int partitionIndex = atoi(fileName + baseNameLen + 1); + // Don't forget the 's' of slice :) + memcpy(baseDeviceName, fileName, baseNameLen); + baseDeviceName[baseNameLen] = '\0'; + + // open base device + int baseFD = open(baseDeviceName, O_RDONLY); + if (baseFD < 0) { + fprintf(stderr, "Error: Failed to open \"%s\": %s\n", + baseDeviceName, strerror(errno)); + exit(1); + } + + // get device size + int64 deviceSize; + if (ioctl(baseFD, DIOCGMEDIASIZE, &deviceSize) == -1) { + fprintf(stderr, "Error: Failed to get device geometry " + "for \"%s\": %s\n", baseDeviceName, + strerror(errno)); + exit(1); + } + + // parse the partition map + PartitionMapParser parser(baseFD, 0, deviceSize); + PartitionMap map; + error = parser.Parse(NULL, &map); + if (error != B_OK) { + fprintf(stderr, "Error: Parsing partition table on " + "device \"%s\" failed: %s\n", baseDeviceName, + strerror(error)); + exit(1); + } + + close(baseFD); + + // check the partition we are supposed to write at + Partition *partition = map.PartitionAt(partitionIndex - 1); + if (!partition || partition->IsEmpty()) { + fprintf(stderr, "Error: Invalid partition index %d.\n", + partitionIndex); + exit(1); + } + + if (partition->IsExtended()) { + fprintf(stderr, "Error: Partition %d is an extended " + "partition.\n", partitionIndex); + exit(1); + } + + partitionOffset = partition->Offset(); + + } else { + // The given device is the base device. We'll write at + // offset 0. + } + + #endif // HAIKU_HOST_PLATFORM_FREEBSD + } else if (S_ISBLK(st.st_mode)) { // block device: a device or partition under Linux #ifdef HAIKU_HOST_PLATFORM_LINUX Modified: haiku/trunk/src/build/libroot/Jamfile =================================================================== --- haiku/trunk/src/build/libroot/Jamfile 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/build/libroot/Jamfile 2008-02-05 20:54:42 UTC (rev 23880) @@ -27,6 +27,11 @@ strlSources = strlcpy.c strlcat.c ; } +local hostPlatformSources ; +if $(HOST_PLATFORM) = freebsd { + hostPlatformSources = fs_freebsd.cpp ; +} + BuildPlatformSharedLibrary libroot_build.so : atomic.cpp byteorder.cpp @@ -38,6 +43,8 @@ sem.cpp thread.cpp + $(hostPlatformSources) + $(strlSources) strnlen.c Modified: haiku/trunk/src/build/libroot/fs.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs.cpp 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/build/libroot/fs.cpp 2008-02-05 20:54:42 UTC (rev 23880) @@ -1,3 +1,7 @@ +/* + * Copyright 2005-2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ #include @@ -22,10 +26,28 @@ #include "fs_descriptors.h" #include "NodeRef.h" +#if defined(HAIKU_HOST_PLATFORM_FREEBSD) +# include "fs_freebsd.h" +#endif + + using namespace std; using namespace BPrivate; +#if defined(HAIKU_HOST_PLATFORM_FREEBSD) +# define haiku_host_platform_read haiku_freebsd_read +# define haiku_host_platform_write haiku_freebsd_write +# define haiku_host_platform_readv haiku_freebsd_readv +# define haiku_host_platform_writev haiku_freebsd_writev +#else +# define haiku_host_platform_read read +# define haiku_host_platform_write write +# define haiku_host_platform_readv readv +# define haiku_host_platform_writev writev +#endif + + static status_t get_path(dev_t device, ino_t node, const char *name, string &path); @@ -583,7 +605,8 @@ } // read - ssize_t bytesRead = read(descriptor->fd, buffer, bufferSize); + ssize_t bytesRead = haiku_host_platform_read(descriptor->fd, buffer, + bufferSize); if (bytesRead < 0) return errno; @@ -608,7 +631,8 @@ } // read - ssize_t bytesWritten = write(descriptor->fd, buffer, bufferSize); + ssize_t bytesWritten = haiku_host_platform_write(descriptor->fd, buffer, + bufferSize); if (bytesWritten < 0) return errno; @@ -932,7 +956,7 @@ return errno; // read - ssize_t bytesRead = read(fd, buffer, bufferSize); + ssize_t bytesRead = haiku_host_platform_read(fd, buffer, bufferSize); if (bytesRead < 0) { errno = bytesRead; return -1; @@ -949,9 +973,9 @@ off_t result = lseek(fd, pos, SEEK_SET); if (result < 0) return errno; - + // read - ssize_t bytesWritten = write(fd, buffer, bufferSize); + ssize_t bytesWritten = haiku_host_platform_write(fd, buffer, bufferSize); if (bytesWritten < 0) { errno = bytesWritten; return -1; @@ -970,7 +994,7 @@ return errno; // read - ssize_t bytesRead = readv(fd, vec, count); + ssize_t bytesRead = haiku_host_platform_readv(fd, vec, count); if (bytesRead < 0) { errno = bytesRead; return -1; @@ -989,7 +1013,7 @@ return errno; // read - ssize_t bytesWritten = writev(fd, vec, count); + ssize_t bytesWritten = haiku_host_platform_writev(fd, vec, count); if (bytesWritten < 0) { errno = bytesWritten; return -1; Added: haiku/trunk/src/build/libroot/fs_freebsd.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs_freebsd.cpp 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/build/libroot/fs_freebsd.cpp 2008-02-05 20:54:42 UTC (rev 23880) @@ -0,0 +1,254 @@ +/* + * Copyright 2008, Samuel Rodriguez Perez, samuelgaliza at gmail.com. + * Distributed under the terms of the MIT License. + */ + +#include "fs_freebsd.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// Read and write operations in FreeBSD only work on devices block by block. + +ssize_t +haiku_freebsd_read(int fd, void *buf, size_t nbytes) +{ + struct stat st; + if (fstat(fd, &st) != 0) + return -1; + + if (S_ISREG(st.st_mode)) + return read(fd, buf, nbytes); // Is a file! Good :) + + int sectorSize; + if (ioctl(fd, DIOCGSECTORSIZE, §orSize) == -1) + sectorSize = 512; // If fail, hardcode to 512 for now + + off_t cur = lseek(fd, 0, SEEK_CUR); + if (cur == -1) + perror("lseek 1"); + + off_t seekDiff = (sectorSize - (cur % sectorSize)) % sectorSize; + off_t nbytesDiff = (nbytes - seekDiff) % sectorSize; + + if (seekDiff == 0 && nbytesDiff == 0) { + // Not needed but this saves malloc and free operations + return read(fd, buf, nbytes); + + } else if (cur % sectorSize + nbytes <= sectorSize) { + // Read complete in only a block + char* tmpBlock = (char*)malloc(sectorSize); + + // Put at start of the block + off_t sdCur = lseek(fd, -(cur % sectorSize), SEEK_CUR); + if (sdCur == -1) + perror("lseek oneblock"); + if (read(fd, tmpBlock, sectorSize) == -1) + perror("read oneblock"); + memcpy((char*)buf, tmpBlock + cur % sectorSize, nbytes); + // repos at byte offset of latest wrote block + if (lseek(fd, -sectorSize + (cur % sectorSize) + nbytes, SEEK_CUR) + == -1) { + perror("lseek2 oneblock"); + } + + free(tmpBlock); + + return nbytes; + + } else { + // Needs to write more than a block + + char* tmpBlock = (char*)malloc(sectorSize); + + // First block if seek isn't + if (seekDiff > 0) { + // read entire block at 0 pos + if (lseek(fd, -(sectorSize - seekDiff), SEEK_CUR) == -1) + perror("lseek seekDiff"); + off_t sdCur = lseek(fd,0,SEEK_CUR); + if (sdCur == -1) + perror("lseek2 seekDiff"); + if (read(fd, tmpBlock, sectorSize) == -1 ) + perror("read seekDiff"); + // alter content + memcpy(buf, tmpBlock + (sectorSize - seekDiff), seekDiff); + + } + + // Blocks between + if ((nbytes - seekDiff) >= sectorSize) { + if (read(fd, ((char*)buf) + seekDiff, nbytes - seekDiff - nbytesDiff) == -1) + perror("read between"); + } + + // Last block if overflow + if (nbytesDiff > 0 ) { + + off_t sdCur = lseek(fd, 0, SEEK_CUR); + if (sdCur == -1) + perror("lseek last"); + if (read(fd, tmpBlock, sectorSize) == -1) + perror("read last"); + memcpy(((char*)buf) + nbytes - nbytesDiff, tmpBlock, nbytesDiff); + // repos at byte offset of latest wrote block + if (lseek(fd, -(sectorSize - nbytesDiff), SEEK_CUR) == -1) + perror("lseek2 last"); + } + + free(tmpBlock); + + return nbytes; + } + +} + + +ssize_t +haiku_freebsd_write(int fd, const void *buf, size_t nbytes) +{ + struct stat st; + if (fstat(fd, &st) != 0) + return -1; + + if (S_ISREG(st.st_mode)) + return write(fd, buf, nbytes); // Is a file! Good :) + + int sectorSize; + if (ioctl(fd, DIOCGSECTORSIZE, §orSize) == -1) + sectorSize = 512; // If fail, hardcode do 512 for now + + off_t cur = lseek(fd, 0, SEEK_CUR); + if (cur == -1) + perror("lseek 1"); + + off_t seekDiff = (sectorSize - (cur % sectorSize)) % sectorSize; + off_t nbytesDiff = (nbytes - seekDiff) % sectorSize; + + if (seekDiff == 0 && nbytesDiff == 0) { + // Not needed but this saves malloc and free operations + return write(fd, buf, nbytes); + + } else if (cur % sectorSize + nbytes <= sectorSize) { + // Write complete in only a block + char* tmpBlock = (char*)malloc(sectorSize); + + // Put at start of the block + off_t sdCur = lseek(fd, -(cur % sectorSize), SEEK_CUR); + if (sdCur == -1) + perror("lseek oneblock"); + if (pread(fd, tmpBlock, sectorSize, sdCur) == -1) + perror("pread oneblock"); + memcpy(tmpBlock + cur % sectorSize, (char*)buf, nbytes); + if (write(fd, tmpBlock, sectorSize) == -1) + perror("write oneblock"); + // repos at byte offset of latest written block + if (lseek(fd, -sectorSize + (cur % sectorSize) + nbytes, SEEK_CUR) == -1) + perror("lseek2 oneblock"); + + free(tmpBlock); + + return nbytes; + + } else { + // Needs to write more than a block + + char* tmpBlock = (char*)malloc(sectorSize); + + // First block if seek isn't + if (seekDiff > 0) { + // read entire block at 0 pos + if (lseek(fd, -(sectorSize - seekDiff), SEEK_CUR) == -1) + perror("lseek seekDiff"); + off_t sdCur = lseek(fd, 0, SEEK_CUR); + if (sdCur == -1) + perror("lseek2 seekDiff"); + if (pread(fd, tmpBlock, sectorSize, sdCur) == -1 ) + perror("pread seekDiff"); + // alter content + memcpy(tmpBlock + (sectorSize - seekDiff), buf, seekDiff); + if (write(fd, tmpBlock, sectorSize)==-1) + perror("write seekDiff"); + + } + + // Blocks between + if ((nbytes - seekDiff) >= sectorSize) { + if (write(fd, ((char*)buf) + seekDiff, nbytes - seekDiff - nbytesDiff) == -1) + perror("write between"); + } + + // Last block if overflow + if (nbytesDiff > 0) { + + off_t sdCur = lseek(fd, 0, SEEK_CUR); + if (sdCur == -1) + perror("lseek last"); + if (pread(fd, tmpBlock, sectorSize, sdCur) == -1) + perror("pread last"); + memcpy(tmpBlock, ((char*)buf) + nbytes - nbytesDiff, nbytesDiff); + if (write(fd, tmpBlock, sectorSize) == -1) + perror("write last"); + // repos at byte offset of latest wrote block + if (lseek(fd, -(sectorSize - nbytesDiff), SEEK_CUR) == -1) + perror("lseek2 last"); + } + + free(tmpBlock); + + return nbytes; + } + +} + + +ssize_t +haiku_freebsd_readv(int fd, const iovec *vecs, size_t count) +{ + ssize_t bytesRead = 0; + + for (size_t i = 0; i < count; i++) { + ssize_t currentRead = haiku_freebsd_read(fd, vecs[i].iov_base, + vecs[i].iov_len); + + if (currentRead < 0) + return bytesRead > 0 ? bytesRead : -1; + + bytesRead += currentRead; + + if ((size_t)currentRead != vecs[i].iov_len) + break; + } + + return bytesRead; +} + + +ssize_t +haiku_freebsd_writev(int fd, const struct iovec *vecs, size_t count) +{ + ssize_t bytesWritten = 0; + + for (size_t i = 0; i < count; i++) { + ssize_t written = haiku_freebsd_write(fd, vecs[i].iov_base, + vecs[i].iov_len); + + if (written < 0) + return bytesWritten > 0 ? bytesWritten : -1; + + bytesWritten += written; + + if ((size_t)written != vecs[i].iov_len) + break; + } + + return bytesWritten; +} Added: haiku/trunk/src/build/libroot/fs_freebsd.h =================================================================== --- haiku/trunk/src/build/libroot/fs_freebsd.h 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/build/libroot/fs_freebsd.h 2008-02-05 20:54:42 UTC (rev 23880) @@ -0,0 +1,17 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef FS_FREEBSD_H +#define FS_FREEBSD_H + +#include + + +ssize_t haiku_freebsd_read(int fd, void *buf, size_t nbytes); +ssize_t haiku_freebsd_write(int fd, const void *buf, size_t nbytes); +ssize_t haiku_freebsd_readv(int fd, const iovec *vecs, size_t count); +ssize_t haiku_freebsd_writev(int fd, const struct iovec *vecs, size_t count); + + +#endif // FS_FREEBSD_H Modified: haiku/trunk/src/tools/fs_shell/uio.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/uio.cpp 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/tools/fs_shell/uio.cpp 2008-02-05 20:54:42 UTC (rev 23880) @@ -41,7 +41,11 @@ if (!prepare_iovecs(vector, count, systemVecs)) return -1; - return readv(fd, systemVecs, count); + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + return readv(fd, systemVecs, count); + #else + return readv_pos(fd, lseek(fd, 0, SEEK_CUR), systemVecs, count); + #endif } @@ -64,7 +68,11 @@ if (!prepare_iovecs(vector, count, systemVecs)) return -1; - return writev(fd, systemVecs, count); + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + return writev(fd, systemVecs, count); + #else + return writev_pos(fd, lseek(fd, 0, SEEK_CUR), systemVecs, count); + #endif } Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-05 20:21:44 UTC (rev 23879) +++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-05 20:54:42 UTC (rev 23880) @@ -22,6 +22,9 @@ # if defined(HAIKU_HOST_PLATFORM_FREEBSD) \ || defined(HAIKU_HOST_PLATFORM_DARWIN) # include +# include +# include +# include # else // the (POSIX) correct place of definition for ioctl() # include @@ -195,9 +198,56 @@ } else error = errno; + #elif HAIKU_HOST_PLATFORM_FREEBSD + { + // FreeBSD has not block devices + + struct stat status; + + if (fstat(fd, &status) == 0) { + struct disklabel disklabel; + off_t mediaSize; + + memset(&disklabel,0,sizeof disklabel); + + // Ignore errors, this way we can use memory devices (md%d) + ioctl(fd, DIOCGSECTORSIZE, &disklabel.d_secsize); + ioctl(fd, DIOCGFWSECTORS, &disklabel.d_nsectors); + ioctl(fd, DIOCGFWHEADS, &disklabel.d_ntracks); + ioctl(fd, DIOCGMEDIASIZE, &mediaSize); + + if (disklabel.d_nsectors == 0) { + // Seems to be a md device, then ioctls returns lots of + // zeroes and hardcode some defaults + disklabel.d_nsectors = 64; + disklabel.d_ntracks = 16; + } + + disklabel.d_secperunit = mediaSize / disklabel.d_secsize; + disklabel.d_ncylinders = mediaSize / disklabel.d_secsize + / disklabel.d_nsectors + / disklabel.d_ntracks; + + geometry->head_count = disklabel.d_ntracks; + geometry->cylinder_count = disklabel.d_ncylinders; + geometry->sectors_per_track = disklabel.d_nsectors; + + geometry->bytes_per_sector = disklabel.d_secsize; + // FreeBSD supports device_type flag as disklabel.d_type, + // for now we harcod it to B_DISK. + geometry->device_type = FSSH_B_DISK; + geometry->removable = disklabel.d_flags & D_REMOVABLE > 0; + // read_only? + geometry->read_only = false; + // FreeBSD does not support write_once flag. + geometry->write_once = false; + error = B_OK; + } else + error = errno; + } #else // Not implemented for this platform, i.e. we won't be able to - // deal with block devices. + // deal with disk devices. #endif break; @@ -245,7 +295,11 @@ fssh_ssize_t fssh_read(int fd, void *buffer, fssh_size_t count) { - return read(fd, buffer, count); + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + return read(fd, buffer, count); + #else + return read_pos(fd, lseek(fd, 0, SEEK_CUR), buffer, count); + #endif } @@ -259,7 +313,11 @@ fssh_ssize_t fssh_write(int fd, const void *buffer, fssh_size_t count) { - return write(fd, buffer, count); + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + return write(fd, buffer, count); + #else + return write_pos(fd, lseek(fd, 0, SEEK_CUR), buffer, count); + #endif } From axeld at mail.berlios.de Tue Feb 5 23:15:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Feb 2008 23:15:16 +0100 Subject: [Haiku-commits] r23881 - haiku/trunk/src/add-ons/kernel/busses/agp_gart Message-ID: <200802052215.m15MFGKU011873@sheep.berlios.de> Author: axeld Date: 2008-02-05 23:15:15 +0100 (Tue, 05 Feb 2008) New Revision: 23881 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23881&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp Log: * Added bridge device ID for i865. * Added other IDs from the graphics driver, but I need to look up their bridge IDs before actually adding them. Modified: haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp 2008-02-05 20:54:42 UTC (rev 23880) +++ haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp 2008-02-05 22:15:15 UTC (rev 23881) @@ -45,6 +45,19 @@ uint32 type; const char *name; } kSupportedDevices[] = { +// {0x3577, INTEL_TYPE_83x, "i830GM"}, +// {0x2562, INTEL_TYPE_83x, "i845G"}, + + {0x2570, 0x2572, INTEL_TYPE_85x, "i865G"}, +// {0x3582, INTEL_TYPE_85x, "i855G"}, + +// {0x2792, INTEL_TYPE_91x, "i910"}, +// {0x258a, INTEL_TYPE_91x, "i915"}, +// {0x2582, INTEL_TYPE_91x, "i915G"}, +// {0x2592, INTEL_TYPE_91x, "i915GM"}, +// {0x2772, INTEL_TYPE_945, "i945G"}, +// {0x27a2, INTEL_TYPE_945, "i945GM"}, +// {0x29a2, INTEL_TYPE_965, "i965G"}, {0x29b0, 0x29b2, INTEL_TYPE_G33, "G33"}, {0x29c0, 0x29c2, INTEL_TYPE_G33, "Q35"}, {0x29d0, 0x29d2, INTEL_TYPE_G33, "Q33"}, From axeld at mail.berlios.de Tue Feb 5 23:18:15 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Feb 2008 23:18:15 +0100 Subject: [Haiku-commits] r23882 - haiku/trunk/build/jam Message-ID: <200802052218.m15MIFmR012023@sheep.berlios.de> Author: axeld Date: 2008-02-05 23:18:14 +0100 (Tue, 05 Feb 2008) New Revision: 23882 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23882&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/NetBootArchive Log: Added ipro100 driver. Tested on real hardware and it seems to work fine. This also closes ticket #1748. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-05 22:15:15 UTC (rev 23881) +++ haiku/trunk/build/jam/HaikuImage 2008-02-05 22:18:14 UTC (rev 23882) @@ -121,7 +121,7 @@ BEOS_ADD_ONS_DRIVERS_MIDI = emuxki ; BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)via_rhine wb840 net_stack - $(X86_ONLY)nforce #vlance + $(X86_ONLY)ipro100 $(X86_ONLY)nforce #vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; Modified: haiku/trunk/build/jam/NetBootArchive =================================================================== --- haiku/trunk/build/jam/NetBootArchive 2008-02-05 22:15:15 UTC (rev 23881) +++ haiku/trunk/build/jam/NetBootArchive 2008-02-05 22:18:14 UTC (rev 23882) @@ -20,7 +20,7 @@ BEOS_NETWORK_PROTOCOLS = ipv4 tcp udp icmp ; BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 - $(X86_ONLY)rtl8139 rtl8169 sis900 + $(X86_ONLY)ipro100 $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)marvell_yukon $(X86_ONLY)via_rhine wb840 net_stack vlance $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; From bonefish at mail.berlios.de Wed Feb 6 00:59:20 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 00:59:20 +0100 Subject: [Haiku-commits] r23883 - haiku/trunk/src/system/boot/platform/pxe_ia32 Message-ID: <200802052359.m15NxKTO027703@sheep.berlios.de> Author: bonefish Date: 2008-02-06 00:59:17 +0100 (Wed, 06 Feb 2008) New Revision: 23883 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23883&view=rev Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/smp_trampoline.S Log: Applied r23800 to the PXE trampoline code, too. Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/smp_trampoline.S =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/smp_trampoline.S 2008-02-05 22:18:14 UTC (rev 23882) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/smp_trampoline.S 2008-02-05 23:59:17 UTC (rev 23883) @@ -47,6 +47,11 @@ movl %eax,%cr3 # set the page dir popl %eax # get the final stack location + + // Clear the final stack location to notify the startup code that + // we loaded the address and it is now safe to be overwritten. + pushl $0x00000000 + movl %eax,%esp // load an address for an indirect jump From mmlr at mlotz.ch Wed Feb 6 08:50:53 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Wed, 6 Feb 2008 08:50:53 +0100 Subject: [Haiku-commits] r23883 - haiku/trunk/src/system/boot/platform/pxe_ia32 In-Reply-To: <200802052359.m15NxKTO027703@sheep.berlios.de> References: <200802052359.m15NxKTO027703@sheep.berlios.de> Message-ID: <20080206074940.M1850@mlotz.ch> On Wed, 6 Feb 2008 00:59:20 +0100, bonefish at BerliOS wrote > Author: bonefish > Date: 2008-02-06 00:59:17 +0100 (Wed, 06 Feb 2008) > New Revision: 23883 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23883&view=rev > > Modified: > haiku/trunk/src/system/boot/platform/pxe_ia32/smp_trampoline.S > Log: > Applied r23800 to the PXE trampoline code, too. Oops, sorry about that. I must have forgotten that the PXE bootloader has its own trampoline code. Thanks for noticing and fixing! Regards Michael From bonefish at mail.berlios.de Wed Feb 6 11:18:05 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:18:05 +0100 Subject: [Haiku-commits] r23884 - haiku/branches Message-ID: <200802061018.m16AI5x7022565@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:18:04 +0100 (Wed, 06 Feb 2008) New Revision: 23884 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23884&view=rev Removed: haiku/branches/vendor/ Log: Removing obsolete vendor branch directory. Contains only QOCA which we no longer use. From bonefish at mail.berlios.de Wed Feb 6 11:26:53 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:26:53 +0100 Subject: [Haiku-commits] r23885 - in haiku/vendor: . lpsolve lpsolve/current lpsolve/current/bfp lpsolve/current/bfp/bfp_LUSOL lpsolve/current/bfp/bfp_LUSOL/LUSOL lpsolve/current/colamd lpsolve/current/demo lpsolve/current/lp_solve lpsolve/current/lpsolve55 lpsolve/current/shared Message-ID: <200802061026.m16AQrZf023062@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:26:35 +0100 (Wed, 06 Feb 2008) New Revision: 23885 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23885&view=rev Added: haiku/vendor/lpsolve/ haiku/vendor/lpsolve/current/ haiku/vendor/lpsolve/current/Makefile haiku/vendor/lpsolve/current/Makefile.Linux haiku/vendor/lpsolve/current/Makefile.in haiku/vendor/lpsolve/current/Makefile.msc haiku/vendor/lpsolve/current/README.txt haiku/vendor/lpsolve/current/bfp/ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Afile3.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL-overview.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_LGPL.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_Overview.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_README.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Row-based L0.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Victoria1850.RUA haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/bfile3.txt haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/commonlib.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/commonlib.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/hbio.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/hbio.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol1.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol2.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol6a.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol6l0.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol6u.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol7a.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusol8a.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusolio.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusolio.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusolmain.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/lusolmain.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/mmio.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/mmio.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/myblas.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/myblas.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/sherman5.mtx haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/sherman5_rhs1.mtx haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/sparselib.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/sparselib.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/bfp_LUSOL.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/bfp_LUSOL.h haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/lp_LUSOL.c haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/lp_LUSOL.h haiku/vendor/lpsolve/current/bfp/lp_BFP.h haiku/vendor/lpsolve/current/bfp/lp_BFP1.c haiku/vendor/lpsolve/current/bfp/lp_BFP2.c haiku/vendor/lpsolve/current/colamd/ haiku/vendor/lpsolve/current/colamd/colamd.c haiku/vendor/lpsolve/current/colamd/colamd.h haiku/vendor/lpsolve/current/configure haiku/vendor/lpsolve/current/configure.ac haiku/vendor/lpsolve/current/declare.h haiku/vendor/lpsolve/current/demo/ haiku/vendor/lpsolve/current/demo/cbcc32.bat haiku/vendor/lpsolve/current/demo/ccc haiku/vendor/lpsolve/current/demo/ccc.osx haiku/vendor/lpsolve/current/demo/cgcc.bat haiku/vendor/lpsolve/current/demo/cvc6.bat haiku/vendor/lpsolve/current/demo/cvc8.bat haiku/vendor/lpsolve/current/demo/demo.c haiku/vendor/lpsolve/current/demo/demo.sln haiku/vendor/lpsolve/current/demo/demo.vcproj haiku/vendor/lpsolve/current/demo/demolib.sln haiku/vendor/lpsolve/current/demo/demolib.vcproj haiku/vendor/lpsolve/current/demo/readme.txt haiku/vendor/lpsolve/current/fortify.c haiku/vendor/lpsolve/current/fortify.h haiku/vendor/lpsolve/current/ini.c haiku/vendor/lpsolve/current/ini.h haiku/vendor/lpsolve/current/lp_Hash.c haiku/vendor/lpsolve/current/lp_Hash.h haiku/vendor/lpsolve/current/lp_MDO.c haiku/vendor/lpsolve/current/lp_MDO.h haiku/vendor/lpsolve/current/lp_MPS.c haiku/vendor/lpsolve/current/lp_MPS.h haiku/vendor/lpsolve/current/lp_SOS.c haiku/vendor/lpsolve/current/lp_SOS.h haiku/vendor/lpsolve/current/lp_crash.c haiku/vendor/lpsolve/current/lp_crash.h haiku/vendor/lpsolve/current/lp_explicit.h haiku/vendor/lpsolve/current/lp_fortify.h haiku/vendor/lpsolve/current/lp_lib.c haiku/vendor/lpsolve/current/lp_lib.h haiku/vendor/lpsolve/current/lp_matrix.c haiku/vendor/lpsolve/current/lp_matrix.h haiku/vendor/lpsolve/current/lp_mipbb.c haiku/vendor/lpsolve/current/lp_mipbb.h haiku/vendor/lpsolve/current/lp_params.c haiku/vendor/lpsolve/current/lp_presolve.c haiku/vendor/lpsolve/current/lp_presolve.h haiku/vendor/lpsolve/current/lp_price.c haiku/vendor/lpsolve/current/lp_price.h haiku/vendor/lpsolve/current/lp_pricePSE.c haiku/vendor/lpsolve/current/lp_pricePSE.h haiku/vendor/lpsolve/current/lp_report.c haiku/vendor/lpsolve/current/lp_report.h haiku/vendor/lpsolve/current/lp_rlp.bat haiku/vendor/lpsolve/current/lp_rlp.c haiku/vendor/lpsolve/current/lp_rlp.h haiku/vendor/lpsolve/current/lp_rlp.l haiku/vendor/lpsolve/current/lp_rlp.y haiku/vendor/lpsolve/current/lp_scale.c haiku/vendor/lpsolve/current/lp_scale.h haiku/vendor/lpsolve/current/lp_simplex.c haiku/vendor/lpsolve/current/lp_simplex.h haiku/vendor/lpsolve/current/lp_solve.def haiku/vendor/lpsolve/current/lp_solve/ haiku/vendor/lpsolve/current/lp_solve/10 haiku/vendor/lpsolve/current/lp_solve/11 haiku/vendor/lpsolve/current/lp_solve/Makefile.msc haiku/vendor/lpsolve/current/lp_solve/c haiku/vendor/lpsolve/current/lp_solve/cbcc32.bat haiku/vendor/lpsolve/current/lp_solve/ccc haiku/vendor/lpsolve/current/lp_solve/ccc.osx haiku/vendor/lpsolve/current/lp_solve/cgcc.bat haiku/vendor/lpsolve/current/lp_solve/cvc6.bat haiku/vendor/lpsolve/current/lp_solve/cvc6d.bat haiku/vendor/lpsolve/current/lp_solve/lp_solve.c haiku/vendor/lpsolve/current/lp_solve/lp_solve.sln haiku/vendor/lpsolve/current/lp_solve/lp_solve.vcproj haiku/vendor/lpsolve/current/lp_solve/nopresolve haiku/vendor/lpsolve/current/lp_solve/readme.txt haiku/vendor/lpsolve/current/lp_solve/result_netlib.txt haiku/vendor/lpsolve/current/lp_solve/stat.txt haiku/vendor/lpsolve/current/lp_solveDLL.c haiku/vendor/lpsolve/current/lp_solveDLL.h haiku/vendor/lpsolve/current/lp_types.h haiku/vendor/lpsolve/current/lp_utils.c haiku/vendor/lpsolve/current/lp_utils.h haiku/vendor/lpsolve/current/lp_wlp.c haiku/vendor/lpsolve/current/lp_wlp.h haiku/vendor/lpsolve/current/lpkit.h haiku/vendor/lpsolve/current/lpsolve.h haiku/vendor/lpsolve/current/lpsolve55/ haiku/vendor/lpsolve/current/lpsolve55/ccc haiku/vendor/lpsolve/current/lpsolve55/ccc.hp-ux haiku/vendor/lpsolve/current/lpsolve55/ccc.osx haiku/vendor/lpsolve/current/lpsolve55/cccLUSOL.osx haiku/vendor/lpsolve/current/lpsolve55/cg++.bat haiku/vendor/lpsolve/current/lpsolve55/cgcc.bat haiku/vendor/lpsolve/current/lpsolve55/cvc6.bat haiku/vendor/lpsolve/current/lpsolve55/cvc8NOmsvcrt80.bat haiku/vendor/lpsolve/current/lpsolve55/cvc8msvcrt80.bat haiku/vendor/lpsolve/current/lpsolve55/dll.sln haiku/vendor/lpsolve/current/lpsolve55/dll.vcproj haiku/vendor/lpsolve/current/lpsolve55/lib.sln haiku/vendor/lpsolve/current/lpsolve55/lib.vcproj haiku/vendor/lpsolve/current/lpsolve55/lpsolve.rc haiku/vendor/lpsolve/current/lpsolve55/lpsolve55.dll.manifest haiku/vendor/lpsolve/current/lpsolve55/readme.txt haiku/vendor/lpsolve/current/lpsolve55/resource.h haiku/vendor/lpsolve/current/shared/ haiku/vendor/lpsolve/current/shared/commonlib.c haiku/vendor/lpsolve/current/shared/commonlib.h haiku/vendor/lpsolve/current/shared/mmio.c haiku/vendor/lpsolve/current/shared/mmio.h haiku/vendor/lpsolve/current/shared/myblas.c haiku/vendor/lpsolve/current/shared/myblas.h haiku/vendor/lpsolve/current/ufortify.h haiku/vendor/lpsolve/current/yacc_read.c haiku/vendor/lpsolve/current/yacc_read.h Log: Imported lp_solve library version 5.5.0.11, a linear programming solver library. Added: haiku/vendor/lpsolve/current/Makefile =================================================================== --- haiku/vendor/lpsolve/current/Makefile 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/Makefile 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,169 @@ +CC= gcc + +MINGW_EXTRA = c:/cygwin/mingw +MINGW_INCDIR = $(MINGW_EXTRA)/include +MINGW_LIBDIR = $(MINGW_EXTRA)/lib + +AS = as +DLLTOOL = dlltool +DLLWRAP = dllwrap +DLLWRAP_FLAGS = --dlltool-name=$(DLLTOOL) --as=$(AS) --driver-name=$(CC) \ + --target=i386-mingw32 + +DLL_LDFLAGS = -L$(MINGW_LIBDIR) -mno-cygwin -mwindows +DLL_LDLIBS = liblpk.a + +# +# Beginning of supplied stuff +# + +#should be OK in most situations: +#CFLAGS= -O + +# HP/UX 9.0X optimized code +#CFLAGS= +O3 +Oaggressive +Olibcalls -Aa -D_POSIX_SOURCE -DCHECK +FP VZOUiD +# HP/UX 9.0X debugging +#CFLAGS= -g -Aa -D_POSIX_SOURCE -DCHECK +FP VZOUiD + +# nice for gcc +CFLAGS= -O3 -Wall -pedantic -ansi -mrtd +#CFLAGS= -g -Wall -pedantic -ansi +INCLUDE=-Ibfp -Ibfp/bfp_etaPFI -I. -Icolamd -Ishared +CFLAGS= -O3 -Wall -pedantic -ansi -mrtd -mno-cygwin -I$(MINGW_INCDIR)\ +-DINTEGERTIME -DPARSER_LP -DYY_INTERACTIVE -DWIN32 $(INCLUDE) \ +-DBUILDING_FOR_R -DWIN32 -g + +# Option -DCHECK checks for numerical problems during rounding of numbers. +# It will slow things down a bit. +# You can add a -DREAL= to the CFLAGS, to change the default float +# type used in lp_solve (double) to float or 'long double'. However, type float +# might be fast on your computer, but it is not accurate enough to solve even +# moderately sized problems without running into numerical problems. +# The use of long doubles does increase the numerical stability of lp_solve, +# if your compiler actually implements them with more bits than a double. But +# it slows down things quite a bit. + +# Choose your favorite or available version of lex and yacc + +#YACC= yacc +#especially for linux: +YACC= bison -y + +#LEX= lex +#especially for linux: +LEX= flex -l + +#LEXLIB= -ll +#especially for linux: +LEXLIB= -lfl + +#ANSI math lib +#MATHLIB= -lM +#non-ANSI math lib, should also work +MATHLIB= -lm + +LPKSRC.c= $(wildcard *.c) lp_MDO.c \ +colamd/colamd.c shared/commonlib.c shared/myblas.c + +LEXFILE.l= lp_rlp.l +YACCFILE.y= lp_rlp.y + +LPKLIB=liblpk.a + +LEXFILE.c= $(LEXFILE.l:.l=.c) +YACCFILE.c= $(YACCFILE.y:.y=.c) +YACCFILE.o= $(YACCFILE.y:.y=.o) +CSOURCES=$(LEXFILE.c) $(YACCFILE.c) $(wildcard *.c) +# commonlib.c fortify.c lp_Hash.c \ +# lp_LUMOD.c lp_MPS.c lp_SOS.c lp_crash.c lp_lib.c lp_matrix.c lp_mipbb.c \ +# lp_presolve.c lp_price.c lp_pricePSE.c lp_report.c lp_rlp.c lp_scale.c \ +# lp_simplex.c lp_solveDLL.c lp_utils.c lp_wlp.c lpslink.c myblas.c \ +# yacc_read.c +COBJ=$(CSOURCES:.c=.o) +LPKSRC= $(LPKSRC.c) $(YACCFILE.c) +LPKOBJ= $(LPKSRC:.c=.o) +HEADERS=*.h + +all: lpslink.dll + +q8.exe: q8.o + $(CC) -o q8.exe $(CFLAGS) \ +--allow-multiple-definition \ +q8.o colamd/colamd.o shared/commonlib.o \ +fortify.o ini.o \ +lp_Hash.o lp_LUSOL.o lp_MDO.o lp_MPS.o lp_SOS.o lp_crash.o lp_lib.o \ +lp_matrix.o lp_mipbb.o lp_params.o lp_presolve.o lp_price.o lp_pricePSE.o \ +lp_report.o lp_rlp.o lp_scale.o lp_simplex.o lp_utils.o lp_wlp.o lpslink.o \ +lusol.o mmio.o shared/myblas.o yacc_read.o \ +$(MATHLIB) $(LPKLIB) \ +-Wl,--allow-multiple-definition + + +$(COBJ): $(HEADERS) + +purify: lp_solve.o $(LPKLIB) + purify $(CC) -o $(TARGET) $(CFLAGS) lp_solve.o $(LPKLIB) $(LEXLIB) $(MATHLIB) + +quantify: lp_solve.o $(LPKLIB) + quantify $(CC) -o $(TARGET) $(CFLAGS) lp_solve.o $(LPKLIB) $(LEXLIB) $(MATHLIB) + +$(LPKLIB): $(LPKOBJ) + ar rv $@ $(LPKOBJ) + ranlib $(LPKLIB) + +$(YACCFILE.o): $(LEXFILE.c) + +$(LEXFILE.c): $(LEXFILE.l) + $(LEX) $(LEXFILE.l) + mv lex.yy.c $(LEXFILE.c) + +$(YACCFILE.c): $(YACCFILE.y) + $(YACC) $(YACCFILE.y) + mv y.tab.c $(YACCFILE.c) + +# liblpk.def: lpslink.o +# dlltool -z liblpk.def -e exports.o -l liblpk.lib lpslink.o +lpslink.dll: lpslink.o liblpk.def liblpk.a + $(DLLWRAP) $(DLLWRAP_FLAGS) -o $@ --def liblpk.def \ +lpslink.o $(DLL_LDFLAGS) $(DLL_LDLIBS) + + + +test: + -for i in $(TESTFILES1); do\ + ./$(TARGET) -s -S3 -time < $$i > xxx.tmp;\ + if diff xxx.tmp lp_examples/`basename $$i .lp`.out > /dev/null; then\ + echo "$$i gives the correct result";\ + else\ + echo "*** $$i gives different result, please check ***";\ + fi;\ + done;\ + for i in $(TESTFILES2); do\ + ./$(TARGET) -mps -s -S3 -time < $$i > xxx.tmp;\ + if diff xxx.tmp lp_examples/`basename $$i .mps`.out > /dev/null; then\ + echo "$$i gives the correct result";\ + else\ + echo "*** $$i gives different result, please check ***";\ + fi;\ + done;\ + rm xxx.tmp + +mktest: + -for i in $(TESTFILES1); do\ + ./$(TARGET) -s -S3 -time < $$i > lp_examples/`basename $$i .lp`.out;\ + done;\ + for i in $(TESTFILES2); do\ + ./$(TARGET) -mps -s -S3 -time < $$i > lp_examples/`basename $$i .mps`.out;\ + done;\ + +$(TARGET).man: $(TARGET).1 + nroff -man $(TARGET).1 > $(TARGET).man + +MANIFEST: clean + ls -lR > MANIFEST; ls -lR > MANIFEST + +clean: + rm -f *.a *.o TAGS $(LEXFILE.c) $(YACCFILE.c) demo $(TARGET) lp2mps mps2lp .pure .softdebughist datafile + +TAGS: + etags *.[chyl] Added: haiku/vendor/lpsolve/current/Makefile.Linux =================================================================== --- haiku/vendor/lpsolve/current/Makefile.Linux 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/Makefile.Linux 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,83 @@ +# +# Makefile for building lp_solve using GNU Make +# Usage: +# make -f Makefile.Linux [all | bin | lib | clean] +# +# $Revision: 1.1 $ +# + +AR = ar +ARFLAGS = rv +CC = gcc +LEX = flex +YACC = bison + +INCLUDE = -I. -Ibfp -Ibfp/bfp_LUSOL -Ibfp/bfp_LUSOL/LUSOL -Icolamd -Ishared + +# Uncomment any of the following two depending on your profile +#DEBUG = -g -pg +DEBUG = -O2 + +DEFINE = -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine + +# Uncomment any of the following two depending on how easily compiler messages scare you +#CFLAGS= $(INCLUDE) $(DEBUG) $(DEFINE) -fpic -Wall -pedantic -trigraphs +CFLAGS= $(INCLUDE) $(DEBUG) $(DEFINE) -fpic + +LFLAGS = -L -l +YFLAGS = --no-lines -y + +LDFLAGS = -lm -ldl + +LUSOLSRC = bfp/bfp_LUSOL/lp_LUSOL.c bfp/bfp_LUSOL/LUSOL/lusol.c +LUSOLOBJS = bfp/bfp_LUSOL/lp_LUSOL.o bfp/bfp_LUSOL/LUSOL/lusol.o + +OBJECTS = $(LUSOLOBJS) lp_MDO.o shared/commonlib.o colamd/colamd.o \ +shared/mmio.o shared/myblas.o ini.o fortify.o lp_rlp.o lp_crash.o \ +lp_Hash.o lp_lib.o lp_wlp.o lp_matrix.o lp_mipbb.o lp_MPS.o \ +lp_params.o lp_presolve.o lp_price.o lp_pricePSE.o lp_report.o \ +lp_scale.o lp_simplex.o lp_SOS.o lp_utils.o yacc_read.o + +SRC = $(LUSOLSRC) lp_MDO.c shared/commonlib.c colamd/colamd.c \ +shared/mmio.c shared/myblas.c ini.c fortify.c lp_rlp.c lp_crash.c \ +lp_Hash.c lp_lib.c lp_wlp.c lp_matrix.c lp_mipbb.c lp_MPS.c \ +lp_params.c lp_presolve.c lp_price.c lp_pricePSE.c lp_report.c \ +lp_scale.c lp_simplex.c lp_SOS.c lp_utils.c yacc_read.c + +LIBRARIES = liblpsolve55.a liblpsolve55.so +BINARIES = lp_solve demo +ALL = $(BINARIES) $(DEMOS) $(LIBRARIES) +.PHONY=clean lp_solve + +all: $(ALL) +lib: $(LIBRARIES) +bin: $(BINARIES) +objects: $(OBJECTS) + +lp_rlp.o: lp_rlp.l lp_rlp.y + $(LEX) $(LFLAGS) lp_rlp.l + sed -e "s/yy/lp_yy/g" lex.yy.c >lp_rlp.h + rm -f lex.yy.c + + $(YACC) $(YFLAGS) lp_rlp.y + sed -e "s/yy/lp_yy/g" y.tab.c >lp_rlp.c + rm -f y.tab.c + + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INCLUDE) -c $*.c + +lp_solve: lp_solve/lp_solve.c $(OBJECTS) + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INCLUDE) $< $(OBJECTS) -o lp_solve/lp_solve $(LDFLAGS) + +demo: demo/demo.c $(OBJECTS) + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INCLUDE) $< $(OBJECTS) -o demo/demo $(LDFLAGS) + +liblpsolve55.a: $(OBJECTS) + $(AR) $(ARFLAGS) lpsolve55/$@ `echo $(SRC)|sed 's/[.]c/.o/g'` + ranlib lpsolve55/$@ + +liblpsolve55.so: $(OBJECTS) + $(CC) -fpic -shared -Wl,-Bsymbolic -Wl,-soname,$@ -o lpsolve55/$@ `echo $(SRC)|sed 's/[.]c/.o/g'` $(LDFLAGS) + +clean: + rm -f $(OBJECTS) *.so *.a lp_solve/lp_solve demo/demo lpsolve55/*.so lpsolve55/*.a + Added: haiku/vendor/lpsolve/current/Makefile.in =================================================================== --- haiku/vendor/lpsolve/current/Makefile.in 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/Makefile.in 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,131 @@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_STRING=@PACKAGE_NAME at _@PACKAGE_VERSION@ +CCSHARED=@CCSHARED@ +prefix = @prefix@ +includedir = @includedir@/lpsolve +libdir = @libdir@ +CFLAGS=@CFLAGS@ +INCLUDES=-I. -I./shared -I./bfp -I./bfp/bfp_LUSOL -I./bfp/bfp_LUSOL/LUSOL -I./colamd +DEFINES=-DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine @DEF@ +LIBS=-lc -lm -ldl +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL = @INSTALL@ +mkdir_p = mkdir -p +HEADERS = \ + declare.h \ + fortify.h \ + ini.h \ + lp_crash.h \ + lp_explicit.h \ + lp_fortify.h \ + lp_Hash.h \ + lpkit.h \ + lp_lib.h \ + lp_matrix.h \ + lp_MDO.h \ + lp_mipbb.h \ + lp_MPS.h \ + lp_presolve.h \ + lp_price.h \ + lp_pricePSE.h \ + lp_report.h \ + lp_rlp.h \ + lp_scale.h \ + lp_simplex.h \ + lp_solveDLL.h \ + lpsolve.h \ + lp_SOS.h \ + lp_types.h \ + lp_utils.h \ + lp_wlp.h \ + ufortify.h \ + yacc_read.h + +SOURCES = lp_MDO.c \ + shared/commonlib.c \ + shared/mmio.c \ + shared/myblas.c \ + ini.c \ + fortify.c \ + colamd/colamd.c \ + lp_rlp.c \ + lp_crash.c \ + bfp/bfp_LUSOL/lp_LUSOL.c \ + bfp/bfp_LUSOL/LUSOL/lusol.c \ + lp_Hash.c \ + lp_lib.c \ + lp_wlp.c \ + lp_matrix.c \ + lp_mipbb.c \ + lp_MPS.c \ + lp_params.c \ + lp_presolve.c \ + lp_price.c \ + lp_pricePSE.c \ + lp_report.c \ + lp_scale.c \ + lp_simplex.c \ + lp_SOS.c \ + lp_utils.c \ + yacc_read.c + +all: liblpsolve55.a @SHARED_LIB@ + +# OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) +#.c.o: +# $(CC) -s -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(SOURCES) + +liblpsolve55.a: $(SOURCES) + $(CC) -s -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(SOURCES) + ar rv $@ `echo $(SOURCES)|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` + ranlib $@ + +liblpsolve55 at SO@: $(SOURCES) + $(CC) $(CCSHARED) -s -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(SOURCES) + $(CC) -shared -Wl,-Bsymbolic -Wl,-soname,$@ -o $@ `echo $(SOURCES)|sed s/[.]c/.o/g|sed 's/[^ ]*\///g'` $(LIBS) + +install: install-HEADERS install-LIBRARIES + +install-HEADERS: $(HEADERS) + test -d $(includedir) || $(mkdir_p) $(includedir) + @list='$(HEADERS)'; for p in $$list; do \ + echo " $(INSTALL) $$p $(includedir)/$$f"; \ + $(INSTALL) $$p $(includedir)/$$f; \ + done + +install-LIBRARIES: liblpsolve55.a @SHARED_LIB@ + test -d $(libdir) || $(mkdir_p) $(libdir) + @list='liblpsolve55.a @SHARED_LIB@'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL) $$p $(libdir)/$$f"; \ + $(INSTALL) $$p $(libdir)/$$f; \ + else :; fi; \ + done + +uninstall-LIBRARIES: + @set -x; list='liblpsolve55.a @SHARED_LIB@'; for p in $$list; do \ + echo " rm -f $(libdir)/$$f"; \ + rm -f "$(libdir)/$$f"; \ + done + +uninstall: uninstall-HEADERS uninstall-LIBRARIES + +uninstall-HEADERS: + @set -x; @list=$(HEADERS); for p in $$list; do \ + echo " rm -f $(includedir)/$$f"; \ + rm -f "$(includedir)/$$f"; \ + done + +dist: + mkdir $(PACKAGE_STRING) + tar -cpf- -T MANIFEST | (cd $(PACKAGE_STRING) && tar -xpf- ) + tar -czpf $(PACKAGE_STRING).tar.bz2 ./$(PACKAGE_STRING) + -rm -fr $(PACKAGE_STRING) + +CLEANFILES = *.o *.so *.a +clean: + -rm -f $(CLEANFILES) + +.PHONY: install install-HEADERS install-LIBRARIES uninstall uninstall-HEADERS uninstall-LIBRARIES all Added: haiku/vendor/lpsolve/current/Makefile.msc =================================================================== --- haiku/vendor/lpsolve/current/Makefile.msc 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/Makefile.msc 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,89 @@ +# +# Makefile for building lp_solve using GNU Make +# Usage: +# gmake -f Makefile.msc [all | bin | lib | clean] +# +# $Revision: 1.1 $ +# + +AR = ar +ARFLAGS = rv +CC = cl +LEX = flex +YACC = bison + +INC = -I. -Ibfp -Ibfp/bfp_LUSOL -Ibfp/bfp_LUSOL/LUSOL -Icolamd -Ishared + +# Uncomment any of the following two depending on your profile +#DEBUG = -g -pg +DEBUG = /ML /O1 /Zp8 /Gd /W2 /DWIN32 /D_WINDOWS + +DEFINE = -DNoParanoia -DWIN32 -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine + +# Uncomment any of the following two depending on how easily compiler messages scare you +CFLAGS= $(INC) $(DEBUG) $(DEFINE) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE + +LFLAGS = -L -l +YFLAGS = --no-lines -y + +LDFLAGS = + +LUSOLSRC = bfp/bfp_LUSOL/lp_LUSOL.c bfp/bfp_LUSOL/LUSOL/lusol.c +LUSOLOBJS = bfp/bfp_LUSOL/lp_LUSOL.obj bfp/bfp_LUSOL/LUSOL/lusol.obj + +OBJECTS = $(LUSOLOBJS) lp_MDO.obj shared/commonlib.obj colamd/colamd.obj \ +shared/mmio.obj shared/myblas.obj ini.obj fortify.obj lp_rlp.obj lp_crash.obj \ +lp_Hash.obj lp_lib.obj lp_wlp.obj lp_matrix.obj lp_mipbb.obj lp_MPS.obj \ +lp_params.obj lp_presolve.obj lp_price.obj lp_pricePSE.obj lp_report.obj \ +lp_scale.obj lp_simplex.obj lp_SOS.obj lp_utils.obj yacc_read.obj + +SRC = $(LUSOLSRC) lp_MDO.c shared/commonlib.c colamd/colamd.c \ +shared/mmio.c shared/myblas.c ini.c fortify.c lp_rlp.c lp_crash.c \ +lp_Hash.c lp_lib.c lp_wlp.c lp_matrix.c lp_mipbb.c lp_MPS.c \ +lp_params.c lp_presolve.c lp_price.c lp_pricePSE.c lp_report.c \ +lp_scale.c lp_simplex.c lp_SOS.c lp_utils.c yacc_read.c + +#LIBRARIES = liblpsolve55.lib liblpsolve55d.lib lpsolve55.dll +LIBRARIES = +#BINARIES = lp_solve.exe demo.exe +BINARIES = lp_solve.exe +ALL = $(BINARIES) $(DEMOS) $(LIBRARIES) +.PHONY=clean lp_solve + +all: $(ALL) +lib: $(LIBRARIES) +bin: $(BINARIES) +objects: $(OBJECTS) + +$(OBJECTS): $(SRC) + $(CC) -c $(CFLAGS) $(SRC) + +lp_rlp.c: lp_rlp.l lp_rlp.y + $(LEX) $(LFLAGS) lp_rlp.l + sed -e "s/yy/lp_yy/g" lex.yy.c >lp_rlp.h + rm -f lex.yy.c + + $(YACC) $(YFLAGS) lp_rlp.y + sed -e "s/yy/lp_yy/g" y.tab.c >lp_rlp.c + rm -f y.tab.c + + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INC) -c $*.c + +lp_solve.exe: lp_solve/lp_solve.c $(OBJECTS) + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INC) $< $(OBJECTS) -Felp_solve/lp_solve $(LDFLAGS) + +demo.exe: demo/demo.c $(OBJECTS) + $(CC) $(CFLAGS) $(DEBUG) $(DEFINE) $(INC) $< $(OBJECTS) -Fedemo/demo $(LDFLAGS) + +lpsolve.res: lpsolve.rc + $(RC) lpsolve.rc + +liblpsolve55.lib: $(OBJECTS) + $(LIB) *.obj /OUT:lpsolve55/$@ + +lpsolve55.dll: $(OBJECTS) + $(CC) -fpic -shared -Wl,-Bsymbolic -Wl,-soname,$@ -o lpsolve55/$@ `echo $(SRC)|sed 's/[.]c/.obj/g'` $(LDFLAGS) + +clean: + rm -f $(OBJECTS) *.lib *.dll lp_solve/lp_solve.exe demo/demo.exe lpsolve55/*.dll lpsolve55/*.lib + Added: haiku/vendor/lpsolve/current/README.txt =================================================================== --- haiku/vendor/lpsolve/current/README.txt 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/README.txt 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,344 @@ +Introduction +------------ +What is lp_solve and what is it not? +The simple answer is, lp_solve is a Mixed Integer Linear Programming (MILP) solver. + +It is a free (see LGPL for the GNU lesser general public license) linear (integer) programming solver +based on the revised simplex method and the Branch-and-bound method for the integers. +It contains full source, examples and manuals. +lp_solve solves pure linear, (mixed) integer/binary, semi-continuous and +special ordered sets (SOS) models. + +See the reference guide for more information. + + +lp_solve 5.5 +------------ + +Why a jump from version numbers 5.1 to 5.5 ? +This is done to indicate that this is more than just another update. +The solver engine was revised and optimised in such a way that performance has improved considerably. +Numerical stability is also better resulting in more models that can be solved. +The LUSOL bfp is now also the default. In the past, the etaPFI bfp package was the default, +but for larger models this leads faster to numerical instabilities and performance problems. + +Overall, the v5.5 code is faster and more robust than v5.1. +This robustness is for example proven by the fact that many more models can now be solved even without scaling. + +The API hasn't changed very much. +There are a couple of new routines and one routine has an extra argument. +Some constants got new values. + + * Fundamental internal change to the solver engine resulting in better performance and numerical stability. + Both the LP solver and the B&B solvers are enhanced. + * Optimised MILP branch truncation, with reduced cost fixing. + * LUSOL bfp is now the default. + * Presolve is improved in functionality and performance. + * Better handling of degeneracy, with more options. + * Store and read options from a file make it easier to set options. + * Partial pricing for the primal simplex now works. + * Full support for xli_ZIMPL v2.0.3. + * The objective function is no longer stored as part of the constraint matrix. + * Dual-long step code is in place, but not fully activated yet. + * General code cleanup. + * Added OBJSENSE and OBJNAME headers in the free MPS format (See MPS file format). + * The MathProg xli driver has now the ability to generate a model. + * New API routines + +Start by taking a look at 'Changes compared to version 4', 'Changes from version 5.1 to version 5.5' +and 'lp_solve usage' +This gives a good starting point. + + +BFP's +----- + +BFP stands for Basis Factorization Package, which is a unique lp_solve feature. Considerable +effort has been put in this new feature and we have big expectations for this. BFP is a generic +interface model and users can develop their own implementations based on the provided templates. +We are very interested in providing as many different BFPs as possible to the community. + +lp_solve 5.5 has the LUSOL BFP built in as default engine. In addition two other +BFPs are included for both Windows and Linux: bfp_etaPFI.dll, bfp_GLPK.dll for Windows and +libbfp_etaPFI.so, libbfp_GLPK.so for Linux. The bfp_etaPFI includes +advanced column ordering using the COLAMD library, as well as better pivot management for +stability. For complex models, however, the LU factorization approach is much better, and +lp_solve now includes LUSOL as one of the most stable engines available anywhere. LUSOL was +originally developed by Prof. Saunders at Stanford, and it has now been ported to C +and enhanced by Kjell. + +If you compile BFPs yourself, make sure that under Windows, you use __stdcall convention and +use 8 byte alignments. This is needed for the BFPs to work correctly with the general +distribution of lp_solve and also to make sharing BFPs as uncomplicated as possible. + +See the reference guide for more information. + + +XLI's +----- + +XLI stands for eXternal Language Interface, also a unique lp_solve feature. XLI's are stand-alone +libraries used as add-on to lp_solve to make it possible to read and write lp models in a format +not natively supported by lp_solve. Examples are CPLEX lp format, LINDO lp format, MathProg format, +XML format... + +See the reference guide for more information. + + +lpsolve API +----------- + +Don't forget that the API has changed compared to previous versions of lpsolve and that you just +can't use the version 5 lpsolve library with your version 4 or older code. That is also the +reason why the library is now called lpsolve55.dll/lpsolve55.a. lpsolve55.dll or lpsolve55.a are +only needed when you call the lpsolve library via the API interface from your program. +The lp_solve program is still a stand-alone executable program. + +There are examples interfaces for different language like C, VB, C#, VB.NET, Java, +Delphi, and there is now also even a COM object to access the lpsolve library. This means that +the door is wide-open for using lp_solve in many different situations. Thus everything that is +available in version 4 is now also available in version 5 and already much more! + +See the reference guide for more information. + + +Conversion between lp modeling formats +-------------------------------------- + +Note that lp2mps and mps2lp don't exist anymore. However this functionality is now implemented +in lp_solve: + +lp2mps can be simulated as following: +lp_solve -parse_only -lp infile -wmps outfile + +mps2lp can be simulated as following: +lp_solve -parse_only -mps infile -wlp outfile + + +via the -rxli option, a model can be read via an XLI library and via the -wxli option, a model +can be written via an XLI library. + + +How to build the executables yourself. +--------------------------------------- + +At this time, there are no Makefiles yet. However for the time being, there are batch files/scripts +to build. For the Microsoft compiler under Windows, use cvc6.bat, for the gnu compiler under Windows, +use cgcc.bat and for Unix/Linux, use the ccc shell script (sh ccc). + +See the reference guide for more information. + + +IDE +--- + +Under Windows, there is now also a very user friendly lpsolve IDE. Check out LPSolveIDE + +See the reference guide for more information. + + +Documentation (reference guide) +------------------------------- + +See lp_solve55.chm for a Windows HTML help documentation file. +The html files are also in lp_solve_5.5_doc.tar.gz. Start with index.htm +Also see http://lpsolve.sourceforge.net/ for a on-line documentation + + +Change history: +--------------- + +17/05/05 version 5.5.0.0 +- Beta release of version 5.5 + +??/??/05 version 5.5.0.1 +- ? + +26/06/05 version 5.5.0.2 +- ? + +29/06/05 version 5.5.0.3 +- ? + +16/08/05 version 5.5.0.4 +- There are no API changes +- The LUSOL message routine could generate a crash under some cicumstances. Fixed +- A crash could occur when building the model in add_row_mode. Fixed. +- write_params didn't write the PRESOLVE and PRESOLVELOOPS correctly. Fixed. +- write_params didn't write constants with value 0. Fixed. +- The library did not compile under msdev 2002 (VC 7.0 _MSC_VER 1300). Fixed. +- There were some problems with printing long long variables which could generate a crash. Fixed. +- An overflow error could occur because memory was sometimes overwritten. Fixed. +- Presolve routines are revised. They are again improved and made faster. + Also some problems with it are fixed (possible crashes). +- Solver revised. Again made faster and more stable. +- get_row/get_column returned FALSE if the row/column is empty. Fixed. +- get_rowex/get_columnex now returns -1 if and error is detected. This instead of 0. + This to know the distinction between an empty row/column and an error. +- set_bounds had a possible problem when min and max are equal. Fixed. +- A crash/damage error could occur when rows/columns are added after a solve. Fixed. +- The my_chsign macro in lp_types.h gave warnings with some compilers. Fixed. +- The lp_solve program now returns 255 if an unexpected error occurs. Before this was 1 + But this interferes with the lpsolve library return codes. +- With the lp_solve program, debug and print modes were not written correctly in a + specified parameter file. Fixed. +- With the lp_solve program, presolveloops was not set correctly. Fixed. + +17/09/05 version 5.5.0.5 +- In some cases, SOS restrictions were not optimized till optimality. Fixed. +- Presolve sometimes generated 'Column -xxx out of range during presolve' with a possible crash. +- Presolve sometimes removed integer and/or semi-cont variables that should not be deleted. Fixed. +- B&B sometimes didn't find the most optimal solution. Fixed. +- Internal constant COMP_EQUAL renamed to COMP_PREFERNONE because this could interfere with a define + in the standard header files. +- The lp parser had problems with variables starting with INF and there is a + or - sign just before it. + Fixed. +- Added options -presolvem, -presolvefd, -presolvebnd, -presolved, -presolveslk +- Updated documentation. put_bb_branchfunc, put_bb_nodefunc, set_epslevel, dualize_lp, set_basisvar + +16/11/05 version 5.5.0.6 +- set_add_rowmode should not be called after a solve. There is now a test in this routine when this is + done and it then returns FALSE. +- When an empty string ("") as filename is provided to set_outputfile, then output is completely + ignored. +- In some cases, SOS models did not solve to their most optimal solution. +- There was as problem with get_sensitivity_objex. Calling it (sometimes only after multiple times) + resulted in protection errors/core dumps. +- When a model has no constraints, it did not solve most of the times. +- column_in_lp didn't work anymore. +- Large upper bounds could make the model unstable. A change was made to fix this. +- set_improve could let crash the model. +- lp_params.c used the non-ANSI function unlink(). Changed to ANSI function remove(). +- Presolve is again revised considerably. +- SOS handling is improved when there are a lot of SOS constraints. +- Limited constraint-to-SOS1 presolve to constraints with at least 4 variables. +- Limited bound tightening presolve loops. + +12/02/06 version 5.5.0.7 +- When SOS restrictions are added after a previous solve, a crash could occur. +- Optimized renaming a variable when the new name is equal to the old name. +- A possible crash could occur when presolve was enabled +- The constant ANTIDEGEN_DEFAULT is changed. ANTIDEGEN_INFEASIBLE is removed from it. + This constant should not be used unless you have some very tight and hard to solve + models where the optimal solution numerically straddles infeasibility. +- There was a possible problem with set_row(ex). It sometimes wrongfully changed the row. +- When integer variables were scaled, it could happen that because of rounding errors, + a loop was created. +- Sometimes integer models kept on looping in the B&B algorithm. +- A memory overrun could occur when an initial basis is set. This when variable names + are in Rnnn format and constraint names in Cnnn format. +- Some fixes are made in presolve. +- On 64-bit systems, compiler warnings were given and some code worked wrong resulting in + wrong results. +- lp_solve.c didn't compile with some compilers because if a very deep nested if statement. +- The distributed files now have the version number include in the filename. + For example lp_solve_5.5.0.7_exe.zip + This for a possible move to SourceForge in the (near?) future. +- When illegal bounds are specified in the MPS format (lower bound larger than upper bound) + then a warning was given but the illegal bound was just ignored and the model was solved. + This resulted in a solution that did not comply to the original model. Now the message is + seen as an error and solving is aborted. + + +06/09/06 version 5.5.0.8 +- When presolve is active and columns are removed and there are SOS constraints, then presolve + had an error which could result in hanging while solve or maybe wrong solutions. +- set_row(ex) set wrong values when used after a previous solve and scaling is active. +- disabled PRESOLVE_REDUCEMIP since it is very rare that this is effective, and also that it adds + code complications and delayed presolve effects that are not captured properly. +- made routine guess_basis available for all languages (now exported by the dll). + The routine is now also documented. +- some bug corrections in guess_basis. +- Corrected a problem with add_column(ex) when add_rowmode is enabled. +- write_lp now wraps long lines over multiple lines to make it more readable. +- A compilation warning/error sometimes occured on is_fixedvar in lp_lusol.c with some compilers. +- Added options -wxlisol and -wxlisolopt to lp_solve program to write a solution file for those + XLIs that support it. +- Updated CPLEX XLI to support constants in objective. +- Added documentation on infeasible models, guess_basis, DIMACS models, CPLEX format, Zimpl, GNU Mathprog. + Corrected/updated documentation on get_col_name, get_row_name, get_nameindex, write_xli, + External Language Interfaces. +- The mps reader was improved for the rarely cases where the same elements are provided multiple + times. These are now added. +- Revised the java unittest example because it gave some errors that it shouldn't give. + +07/10/06 version 5.5.0.9 +- set_row(ex) could sometimes set wrong values in the model. +- Sometimes models with semi-cont variables which are also integer and scaling is active, a solution + was returned that is not most optimal or it returns infeasible. +- write_mps didn't write semi-cont variables with an infinite upper bound. +- When presolve can solve the model on its own and objective direction is maximize then a wrong sign + was shown in the reported price on screen. +- write_lp writes constraint and bounds in the same way if a constraint is not named. If a constraint + only has one variable then it looks like a bound. This can give problems because when a constraint + is interpreted as bound and it is negative then the problem definition changes. + Therefore a constraint which is not named and having only one variable in it is getting a name to + make sure it is interpreted as a constraint. +- The lp_solve program didn't interprete the PRESOLVED solve return code very well. Fixed. +- bfp_GLPK and xli_MathProg are now compiled against GLPK 4.11 +- When an integer model is aborted before the most optimal solution is found (timeout or + break at first, ...) solve returned OPTIMAL (0) instead of SUBOPTIMAL (1). This is now corrected. + +14/01/07 version 5.5.0.10 +- If a model has integer variables, but the model is already integer optimal in the simplex fase, + then it was reported as suboptimal feasible. +- get_objective, get_variables, get_ptr_variables, get_constraints, get_ptr_constraints, get_primal_solution + reported 'not a valid basis' when presolve is active and the model is entirely solved by presolve. +- presolve on a model with SOS variables sometimes went wrong. +- presolve on a model with SOS variables where infeasibility is detected crashed. +- read_bas could fail when not all constraints had names or had names like default variable names. +- A crash could occur with set_row(ex) in rowmode. +- The lp format has been extended with a free section to define free variables. +- bfp_GLPK and xli_MathProg are now compiled against GLPK 4.13 +- fixed bug in the pseudocost logic that can blow up subsequent pseudocost values in that + branch and make them almost random. +- In some rare cases a memory overrun could occur when constraints are added after a previous solve. +- Made the copy_lp routine work. Note that information about the optimisation of the original model + is not copied (at this time). Only the model is. +- Fixed a bug in the hashing routines that had only influence in some rare cases in the + MATLAB, O-Matrix, Scilab, Octave, Python drivers. +- coldual sometimes worked on a uninitialised variable value with unpredictable results. + +27/12/07 version 5.5.0.11 +- Fixed a problem in presolve. Sometimes an array-index-out-of-bounds error occured. +- Added a makefile for Linux. +- When adding constraints, in some rare cases a memory overrun could occur resulting in a crash. +- add_constraintex with count=0 and row=colno=NULL gave a protection error. + several XLIs didn't work anymore because of this. +- set_constr_type sometimes set wrong signs for the coefficient matrix when add_rowmode is on. +- presolve did an unnecessary extra loop. Also a test is added to stop presolve when very few + changes are done. +- for very large models, a request of much more memory than is reasonable could occur. Fixed. +- Modified LINDO XLI to read keywords also not at column 1 and to accept an empty objective function. + Previously this wat not possible. +- In some rare cases, numbers very close to their integer values (for example 11276.999999999998) + were truncated to their ceiling value (for example 11276) instead of rounded + (for example 11277). +- Solved a problem with presolve with an all-int constraint. +- Solved a problem with presolve coldominate +- Added stronger checking of the MPS format. + Fields that must be blank are now also tested accordingly so that if data is there that it is + not ignored as before. +- FREE MPS format was not read ok if row/column name were all numbers + or a FR, MI, PL, BV bound was defined. Fixed. +- The lp-format now also supports a bin(ary) section to define binary variables. +- When an integer model is aborted before the most optimal solution is found + via break at first or break at value, solve returned OPTIMAL (0) instead of SUBOPTIMAL (1). + This is now corrected. Problem occured in version 5.5.0.10 +- Fixed a problem with del_constraint. Constraints names were not shifted and reported variable result was incorrect. +- read_XLI failed with MathProg if datamodel was provided with "" when there is no datamodel. + NULL was expected in the past. "" is now also accepted. +- Added an XLI to read Xpress lp files. +- Added routines MPS_writefileex, write_lpex. +- Added options -o0, -o1 to lp_solve command driven program to specify if objective is in basis or not. +- Added new information in the reference guide: + - Linear programming basics + - Presolve + - Xpress lp files + +We are thrilled to hear from you and your experiences with this new version. The good and the bad. +Also we would be pleased to hear about your experiences with the different BFPs on your models. + +Please send reactions to: +Peter Notebaert: lpsolve at peno.be +Kjell Eikland: kjell.eikland at broadpark.no Added: haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Afile3.txt =================================================================== --- haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Afile3.txt 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/Afile3.txt 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,6 @@ + 1 1 -0.12264700E+04 + 1 2 0.82867600E+01 + 2 3 0.62150700E+01 + 2 1 0.19468000E+03 + 3 2 -0.23990100E+04 + 3 3 -0.32849100E+04 Added: haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL-overview.txt =================================================================== --- haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL-overview.txt 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL-overview.txt 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,89 @@ + Notes for Contribution of LUSOL to COIN-OR + May 2004 + +Introduction +============ + +LUSOL maintains sparse LU factors of a square or rectangular sparse matrix. It includes a Basis Factorization Package (BFP) suitable for implementing simplex and reduced-gradient methods for optimization. It is a set of routines written in ANSI C (adapted from the original Fortran 77 version). + +LUSOL includes the following features: + +- A Markowitz-based sparse LU factorization for square, + rectangular and possibly singular matrices. + +- Three options for balancing sparsity and stability: + Threshold Partial/Rook/Complete Pivoting (TPP, TRP, TCP). + +- Rank-revealing properties. TRP and TCP are intended for detecting singularities. + +- Dynamic storage allocation (C version only). + +- Stable column replacement as in the method of Bartels and Golub. + +- Other stable updates: add, replace, or delete row or column + (currently F77 version only). + +- Implementation into an easy-to-use BFP API (C version only). + + +Implementation +============== + +The Factor routine is similar to the classical Markowitz routines MA28 and LA05 in the Harwell Subroutine Library. The source matrix nonzeros are stored column-wise with the largest entry at the top of each column. Internally, the structure is also accessible row-wise. All entries in a particular column or row are held in contiguous storage. Fill is accommodated by moving a column or row to the beginning of free storage. Occasional compressions recover storage. This scheme is effective for column-oriented TPP. When the remaining matrix reaches a specified density, the factors are completed using dense processing. + +TRP uses an additional vector of storage to maintain the largest element in each remaining row. + +TCP uses a heap structure to hold the largest element in each column. The largest element in the remaining matrix is then available at the top of the heap. + +The final L is stored column-wise (and never changed). The final U is stored row-wise as a triangular or trapezoidal sparse matrix. + +Column replacements are implemented using a forward sweep of 2-by-2 stabilized elimination matrices. L is updated in product form. U is updated explicitly. + +The other updates use either forward or backward sweeps. They tend to generate more nonzeros than column replacement. + +Both the F77 and C versions contain extensive comments, method and implementational information as part of the code. + +The C version contains a record-based wrapper for the data. Function calls have been simplified by including references to this structure. New maintenance routines enable dynamic instance creation and destruction, and simplifies access to the most frequently used functions. The LUSOL C library is multi-instance and fully re-entrant. All control and output parameters have been given long descriptive names for usability. + + +Benefits +======== + +Rank-revealing properties and rectangular factors (and updates) have not previously been available in sparse LU software. With sensible parameter settings and reasonably scaled data, all routines are numerically stable. The updates may be called hundreds of times, and the decision to refactorize can be based on sparsity considerations alone. + +In the Factor routine, rook pivoting (TRP) gives reliable rank determination without catastrophic degradation in sparsity or speed. Complete pivoting (TCP) is included for moderate-sized matrices and for checking pathological cases (but the factors tend to be substantially more dense). + +To conserve storage, one may request only the row and column pivot orders. The factors are discarded as they are computed. This is useful for basis repair, or for selecting a basis from a rectangular matrix. + + +Known Inefficiencies +==================== + +LUSOL is usually efficient on sparse matrices with dimensions up to about 100,000 (but not millions). + +In the Factor routine, row and column lists must be updated each time a row and column is eliminated. Deleting the pivot row and column is inefficient if the original matrix contains unusually dense rows or columns. For TPP, dense columns could be kept aside and incorporated at the end via updates (but dense rows remain a difficulty). For TRP and TCP, all rows and columns must be present to achieve the required numerical properties. + +For TRP, the current bottleneck is updating the vector containing the largest element in each row. One solution would be to include the matrix nonzeros in the row structure (but this carries its own cost). + +For TCP, the heap structure is already efficient, but the dense factors (and the extended searching for acceptable pivots) are unavoidable expenses. + +The triangular Solve routines do not take full of advantage of sparse right-hand sides. Gilbert and Peierls have shown how to solve Lx = (sparse b) efficiently if L is stored column-wise. Their approach could therefore be implemented in LUSOL for solves with L and U(transpose). Solves with L(transpose) and U would need a second copy of L and U. + + +Original Reference +================== + +P. E. Gill, W. Murray, M. A. Saunders and M. H. Wright, Maintaining LU factors of a general sparse matrix, Linear Algebra and its Applications 88/89, 239-270 (1987). + + +Maintainers +=========== + +F77 version: Michael Saunders (saunders at stanford.edu). +C version: Kjell Eikland (kjell.eikland at broadpark.no). + + +Contributors +============ + +Philip Gill, Walter Murray, Margaret Wright, Michael O'Sullivan. Added: haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_LGPL.txt =================================================================== --- haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_LGPL.txt 2008-02-06 10:18:04 UTC (rev 23884) +++ haiku/vendor/lpsolve/current/bfp/bfp_LUSOL/LUSOL/LUSOL_LGPL.txt 2008-02-06 10:26:35 UTC (rev 23885) @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source [... truncated: 111315 lines follow ...] From bonefish at mail.berlios.de Wed Feb 6 11:28:26 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:28:26 +0100 Subject: [Haiku-commits] r23886 - haiku/vendor/lpsolve Message-ID: <200802061028.m16ASQro023411@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:28:26 +0100 (Wed, 06 Feb 2008) New Revision: 23886 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23886&view=rev Added: haiku/vendor/lpsolve/5.5.0.11/ Log: Tagging lp_solve 5.5.0.11. Copied: haiku/vendor/lpsolve/5.5.0.11 (from rev 23885, haiku/vendor/lpsolve/current) From bonefish at mail.berlios.de Wed Feb 6 11:29:46 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:29:46 +0100 Subject: [Haiku-commits] r23887 - haiku/trunk/src/libs Message-ID: <200802061029.m16ATkHr023473@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:29:46 +0100 (Wed, 06 Feb 2008) New Revision: 23887 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23887&view=rev Added: haiku/trunk/src/libs/lp_solve/ Log: Copying lp_solve 5.5.0.11 to trunk. Copied: haiku/trunk/src/libs/lp_solve (from rev 23886, haiku/vendor/lpsolve/current) From bonefish at mail.berlios.de Wed Feb 6 11:37:19 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:37:19 +0100 Subject: [Haiku-commits] r23888 - in haiku/trunk: headers/libs headers/libs/lp_solve src/libs/lp_solve Message-ID: <200802061037.m16AbJPm024048@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:37:19 +0100 (Wed, 06 Feb 2008) New Revision: 23888 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23888&view=rev Added: haiku/trunk/headers/libs/lp_solve/ haiku/trunk/headers/libs/lp_solve/lp_Hash.h haiku/trunk/headers/libs/lp_solve/lp_SOS.h haiku/trunk/headers/libs/lp_solve/lp_lib.h haiku/trunk/headers/libs/lp_solve/lp_matrix.h haiku/trunk/headers/libs/lp_solve/lp_mipbb.h haiku/trunk/headers/libs/lp_solve/lp_types.h haiku/trunk/headers/libs/lp_solve/lp_utils.h haiku/trunk/src/libs/lp_solve/Jamfile Removed: haiku/trunk/src/libs/lp_solve/lp_Hash.h haiku/trunk/src/libs/lp_solve/lp_SOS.h haiku/trunk/src/libs/lp_solve/lp_lib.h haiku/trunk/src/libs/lp_solve/lp_matrix.h haiku/trunk/src/libs/lp_solve/lp_mipbb.h haiku/trunk/src/libs/lp_solve/lp_types.h haiku/trunk/src/libs/lp_solve/lp_utils.h Log: * Moved public headers to headers/libs/lp_solve. * Added Jamfile by James Kim and Christof Lutteroth. Copied: haiku/trunk/headers/libs/lp_solve/lp_Hash.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_Hash.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_SOS.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_SOS.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_lib.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_lib.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_matrix.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_matrix.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_mipbb.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_mipbb.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_types.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_types.h) Copied: haiku/trunk/headers/libs/lp_solve/lp_utils.h (from rev 23887, haiku/trunk/src/libs/lp_solve/lp_utils.h) Added: haiku/trunk/src/libs/lp_solve/Jamfile =================================================================== --- haiku/trunk/src/libs/lp_solve/Jamfile 2008-02-06 10:29:46 UTC (rev 23887) +++ haiku/trunk/src/libs/lp_solve/Jamfile 2008-02-06 10:37:19 UTC (rev 23888) @@ -0,0 +1,49 @@ +SubDir HAIKU_TOP src libs lp_solve ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +UseLibraryHeaders lp_solve ; + +SubDirCcFlags -s -c -I.. -I../shared -I../bfp -I../bfp/bfp_LUSOL -I../bfp/bfp_LUSOL/LUSOL -I../colamd -O3 -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs lp_solve colamd ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs lp_solve shared ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs lp_solve bfp ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs lp_solve bfp bfp_LUSOL ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src libs lp_solve bfp bfp_LUSOL LUSOL ] ; + +SharedLibrary liblpsolve55.so : + #SubDir + fortify.c + ini.c + lp_crash.c + lp_Hash.c + lp_lib.c + lp_matrix.c + lp_MDO.c + lp_mipbb.c + lp_MPS.c + lp_params.c + lp_presolve.c + lp_price.c + lp_pricePSE.c + lp_report.c + lp_rlp.c + lp_scale.c + lp_simplex.c + lp_SOS.c + lp_utils.c + lp_wlp.c + yacc_read.c + #shared + commonlib.c + mmio.c + myblas.c + #colamd + colamd.c + #bfp_LUSOL + lp_LUSOL.c + #LUSOL + lusol.c +; + Deleted: haiku/trunk/src/libs/lp_solve/lp_Hash.h Deleted: haiku/trunk/src/libs/lp_solve/lp_SOS.h Deleted: haiku/trunk/src/libs/lp_solve/lp_lib.h Deleted: haiku/trunk/src/libs/lp_solve/lp_matrix.h Deleted: haiku/trunk/src/libs/lp_solve/lp_mipbb.h Deleted: haiku/trunk/src/libs/lp_solve/lp_types.h Deleted: haiku/trunk/src/libs/lp_solve/lp_utils.h From bonefish at mail.berlios.de Wed Feb 6 11:51:45 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:51:45 +0100 Subject: [Haiku-commits] r23889 - in haiku/trunk: build/jam headers/libs headers/libs/alm headers/libs/linprog src/libs src/libs/alm src/libs/linprog src/tests src/tests/libs src/tests/libs/alm src/tests/libs/linprog src/tests/libs/lp_solve Message-ID: <200802061051.m16Apjeo025382@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:51:44 +0100 (Wed, 06 Feb 2008) New Revision: 23889 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23889&view=rev Added: haiku/trunk/headers/libs/alm/ haiku/trunk/headers/libs/alm/Area.h haiku/trunk/headers/libs/alm/BALMLayout.h haiku/trunk/headers/libs/alm/Column.h haiku/trunk/headers/libs/alm/LayoutStyleType.h haiku/trunk/headers/libs/alm/Row.h haiku/trunk/headers/libs/alm/XTab.h haiku/trunk/headers/libs/alm/YTab.h haiku/trunk/headers/libs/linprog/ haiku/trunk/headers/libs/linprog/Constraint.h haiku/trunk/headers/libs/linprog/LinearSpec.h haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h haiku/trunk/headers/libs/linprog/OperatorType.h haiku/trunk/headers/libs/linprog/OptimizationType.h haiku/trunk/headers/libs/linprog/PenaltyFunction.h haiku/trunk/headers/libs/linprog/ResultType.h haiku/trunk/headers/libs/linprog/SoftConstraint.h haiku/trunk/headers/libs/linprog/Variable.h haiku/trunk/src/libs/alm/ haiku/trunk/src/libs/alm/Area.cpp haiku/trunk/src/libs/alm/BALMLayout.cpp haiku/trunk/src/libs/alm/Column.cpp haiku/trunk/src/libs/alm/Jamfile haiku/trunk/src/libs/alm/Row.cpp haiku/trunk/src/libs/alm/XTab.cpp haiku/trunk/src/libs/alm/YTab.cpp haiku/trunk/src/libs/linprog/ haiku/trunk/src/libs/linprog/Constraint.cpp haiku/trunk/src/libs/linprog/Jamfile haiku/trunk/src/libs/linprog/LinearSpec.cpp haiku/trunk/src/libs/linprog/ObjFunctionSummand.cpp haiku/trunk/src/libs/linprog/PenaltyFunction.cpp haiku/trunk/src/libs/linprog/SoftConstraint.cpp haiku/trunk/src/libs/linprog/Variable.cpp haiku/trunk/src/tests/libs/ haiku/trunk/src/tests/libs/Jamfile haiku/trunk/src/tests/libs/alm/ haiku/trunk/src/tests/libs/alm/Jamfile haiku/trunk/src/tests/libs/alm/TableTest.cpp haiku/trunk/src/tests/libs/alm/Test1.cpp haiku/trunk/src/tests/libs/alm/Test2.cpp haiku/trunk/src/tests/libs/linprog/ haiku/trunk/src/tests/libs/linprog/Jamfile haiku/trunk/src/tests/libs/linprog/Program.cpp haiku/trunk/src/tests/libs/lp_solve/ haiku/trunk/src/tests/libs/lp_solve/Jamfile haiku/trunk/src/tests/libs/lp_solve/demo.c Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/libs/Jamfile haiku/trunk/src/tests/Jamfile Log: Added libalm.so and its dependency liblinprog.so. libalm.so provides a BLayout implementation (BALMLayout) using the Auckland Layout Model (ALM). The original ALM was implemented by Christof Lutteroth, the Haiku/C++ version by James Kim. The code needs some review, but the test programs seem to work fine. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/build/jam/HaikuImage 2008-02-06 10:51:44 UTC (rev 23889) @@ -65,7 +65,7 @@ libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so - $(X86_ONLY)libGL.so libfluidsynth.so + $(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so ; BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server net_server media_addon_server input_server app_server fake_app_server Added: haiku/trunk/headers/libs/alm/Area.h =================================================================== --- haiku/trunk/headers/libs/alm/Area.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/Area.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,149 @@ +#ifndef AREA_H +#define AREA_H + +#include "Constraint.h" +#include "SoftConstraint.h" + +#include +#include +#include +#include +#include + + +namespace BALM { + +class Column; +class BALMLayout; +class Row; +class XTab; +class YTab; + +/** + * Rectangular area in the GUI, defined by a tab on each side. + */ +class Area { + +public: + bool AutoPrefContentSize() const; + void SetAutoPrefContentSize(bool value); + XTab* Left() const; + void SetLeft(XTab* left); + XTab* Right() const; + void SetRight(XTab* right); + YTab* Top() const; + void SetTop(YTab* top); + YTab* Bottom() const; + void SetBottom(YTab* bottom); + Row* GetRow() const; + void SetRow(Row* row); + Column* GetColumn() const; + void SetColumn(Column* column); + BView* Content() const; + void SetContent(BView* content); + XTab* ContentLeft() const; + YTab* ContentTop() const; + XTab* ContentRight() const; + YTab* ContentBottom() const; + BSize MinContentSize() const; + void SetMinContentSize(BSize min); + BSize MaxContentSize() const; + void SetMaxContentSize(BSize max); + BSize PrefContentSize() const; + void SetPrefContentSize(BSize pref); + BSize ShrinkRigidity() const; + void SetShrinkRigidity(BSize shrink); + BSize ExpandRigidity() const; + void SetExpandRigidity(BSize expand); + double ContentAspectRatio() const; + void SetContentAspectRatio(double ratio); + BAlignment Alignment() const; + void SetAlignment(BAlignment alignment); + void SetHAlignment(alignment horizontal); + void SetVAlignment(vertical_alignment vertical); + int32 LeftInset() const; + void SetLeftInset(int32 left); + int32 TopInset() const; + void SetTopInset(int32 top); + int32 RightInset() const; + void SetRightInset(int32 right); + int32 BottomInset() const; + void SetBottomInset(int32 bottom); + void SetDefaultPrefContentSize(); + //~ string ToString(); + Constraint* HasSameWidthAs(Area* area); + Constraint* HasSameHeightAs(Area* area); + BList* HasSameSizetAs(Area* area); + ~Area(); + +protected: + Area(BALMLayout* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, + BView* content, + BSize minContentSize); + Area(BALMLayout* ls, Row* row, Column* column, + BView* content, + BSize minContentSize); + void DoLayout(); + +private: + void InitChildArea(); + void UpdateHorizontal(); + void UpdateVertical(); + void Init(BALMLayout* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, + BView* content, + BSize minContentSize); + +public: + static BSize kMaxSize; + static BSize kMinSize; + static BSize kUndefinedSize; + +protected: + BView* fContent; + BList* fConstraints; + +private: + BALMLayout* fLS; + XTab* fLeft; + XTab* fRight; + YTab* fTop; + YTab* fBottom; + Row* fRow; + Column* fColumn; + BSize fMinContentSize; + BSize fMaxContentSize; + Constraint* fMinContentWidth; + Constraint* fMaxContentWidth; + Constraint* fMinContentHeight; + Constraint* fMaxContentHeight; + BSize fPrefContentSize; + BSize fShrinkRigidity; + BSize fExpandRigidity; + double fContentAspectRatio; + Constraint* fContentAspectRatioC; + bool fAutoPrefContentSize; + SoftConstraint* fPrefContentWidth; + SoftConstraint* fPrefContentHeight; + Area* fChildArea; + BAlignment fAlignment; + int32 fLeftInset; + int32 fTopInset; + int32 fRightInset; + int32 fBottomInset; + Constraint* fLeftConstraint; + Constraint* fTopConstraint; + Constraint* fRightConstraint; + Constraint* fBottomConstraint; + +public: + friend class BALMLayout; + +}; + +} // namespace BALM + +using BALM::Area; + +#endif // AREA_H Added: haiku/trunk/headers/libs/alm/BALMLayout.h =================================================================== --- haiku/trunk/headers/libs/alm/BALMLayout.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/BALMLayout.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,106 @@ +#ifndef BALM_LAYOUT_H +#define BALM_LAYOUT_H + +#include +#include +#include +#include +#include +#include + +#include "LayoutStyleType.h" +#include "LinearSpec.h" + + +namespace BALM { + +class Area; +class Column; +class Row; +class XTab; +class YTab; + +/** + * A GUI layout engine using the ALM. + */ +class BALMLayout : public BLayout, public LinearSpec { + +public: + BALMLayout(); + void SolveLayout(); + + XTab* AddXTab(); + YTab* AddYTab(); + Row* AddRow(); + Row* AddRow(YTab* top, YTab* bottom); + Column* AddColumn(); + Column* AddColumn(XTab* left, XTab* right); + Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom, + BView* content, BSize minContentSize); + Area* AddArea(Row* row, Column* column, BView* content, + BSize minContentSize); + Area* AddArea(XTab* left, YTab* top, XTab* right, YTab* bottom, + BView* content); + Area* AddArea(Row* row, Column* column, BView* content); + Area* AreaOf(BView* control); + BList* Areas() const; + void SetAreas(BList* areas); + XTab* Left() const; + void SetLeft(XTab* left); + XTab* Right() const; + void SetRight(XTab* right); + YTab* Top() const; + void SetTop(YTab* top); + YTab* Bottom() const; + void SetBottom(YTab* bottom); + + void RecoverLayout(BView* parent); + LayoutStyleType LayoutStyle() const; + void SetLayoutStyle(LayoutStyleType style); + + BLayoutItem* AddView(BView* child); + BLayoutItem* AddView(int32 index, BView* child); + bool AddItem(BLayoutItem* item); + bool AddItem(int32 index, BLayoutItem* item); + bool RemoveView(BView* child); + bool RemoveItem(BLayoutItem* item); + BLayoutItem* RemoveItem(int32 index); + + BSize MinSize(); + BSize MaxSize(); + BSize PreferredSize(); + BAlignment Alignment(); + bool HasHeightForWidth(); + void GetHeightForWidth(float width, float* min, + float* max, float* preferred); + void InvalidateLayout(); + void LayoutView(); + + char* PerformancePath() const; + void SetPerformancePath(char* path); + +private: + BSize CalculateMinSize(); + BSize CalculateMaxSize(); + BSize CalculatePreferredSize(); + +private: + LayoutStyleType fLayoutStyle; + bool fActivated; + + BList* fAreas; + XTab* fLeft; + XTab* fRight; + YTab* fTop; + YTab* fBottom; + BSize fMinSize; + BSize fMaxSize; + BSize fPreferredSize; + char* fPerformancePath; +}; + +} // namespace BALM + +using BALM::BALMLayout; + +#endif // BALM_LAYOUT_H Added: haiku/trunk/headers/libs/alm/Column.h =================================================================== --- haiku/trunk/headers/libs/alm/Column.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/Column.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,58 @@ +#ifndef COLUMN_H +#define COLUMN_H + +#include "Constraint.h" + +#include + + +namespace BALM { + +class BALMLayout; +class XTab; + +/** + * Represents a column defined by two x-tabs. + */ +class Column { + +public: + XTab* Left() const; + XTab* Right() const; + Column* Previous() const; + void SetPrevious(Column* value); + Column* Next() const; + void SetNext(Column* value); + //~ string ToString(); + void InsertBefore(Column* column); + void InsertAfter(Column* column); + Constraint* HasSameWidthAs(Column* column); + BList* Constraints() const; + void SetConstraints(BList* constraints); + ~Column(); + +protected: + Column(BALMLayout* ls); + +protected: + BALMLayout* fLS; + XTab* fLeft; + XTab* fRight; + +private: + Column* fPrevious; + Column* fNext; + Constraint* fPreviousGlue; + Constraint* fNextGlue; + BList* fConstraints; + +public: + friend class BALMLayout; + +}; + +} // namespace BALM + +using BALM::Column; + +#endif // COLUMN_H Added: haiku/trunk/headers/libs/alm/LayoutStyleType.h =================================================================== --- haiku/trunk/headers/libs/alm/LayoutStyleType.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/LayoutStyleType.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,20 @@ +#ifndef LAYOUT_STYLE_TYPE_H +#define LAYOUT_STYLE_TYPE_H + + +namespace BALM { + +/** + * The possibilities for adjusting a GUI's layout. + * Either change the child controls so that they fit into their parent control, or adjust + * the size of the parent control so that the children have as much space as they want. + */ +enum LayoutStyleType { + FIT_TO_SIZE, ADJUST_SIZE +}; + +} // namespace BALM + +using BALM::LayoutStyleType; + +#endif Added: haiku/trunk/headers/libs/alm/Row.h =================================================================== --- haiku/trunk/headers/libs/alm/Row.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/Row.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,58 @@ +#ifndef ROW_H +#define ROW_H + +#include "Constraint.h" + +#include + + +namespace BALM { + +class BALMLayout; +class YTab; + +/** + * Represents a row defined by two y-tabs. + */ +class Row { + +public: + YTab* Top() const; + YTab* Bottom() const; + Row* Previous() const; + void SetPrevious(Row* value); + Row* Next() const; + void SetNext(Row* value); + //~ string ToString(); + void InsertBefore(Row* row); + void InsertAfter(Row* row); + Constraint* HasSameHeightAs(Row* row); + BList* Constraints() const; + void SetConstraints(BList* constraints); + ~Row(); + +protected: + Row(BALMLayout* ls); + +protected: + BALMLayout* fLS; + YTab* fTop; + YTab* fBottom; + +private: + Row* fPrevious; + Row* fNext; + Constraint* fPreviousGlue; + Constraint* fNextGlue; + BList* fConstraints; + +public: + friend class BALMLayout; + +}; + +} // namespace BALM + +using BALM::Row; + +#endif // ROW_H Added: haiku/trunk/headers/libs/alm/XTab.h =================================================================== --- haiku/trunk/headers/libs/alm/XTab.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/XTab.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,38 @@ +#ifndef X_TAB_H +#define X_TAB_H + +#include "Variable.h" + + +namespace BALM { + +class BALMLayout; + +/** + * Vertical grid line (x-tab). + */ +class XTab : public Variable { + +protected: + XTab(BALMLayout* ls); + +protected: + /** + * Property signifying if there is a constraint which relates + * this tab to a different tab that is further to the left. + * Only used for reverse engineering. + */ + bool fLeftLink; + +public: + friend class Area; + friend class Column; + friend class BALMLayout; + +}; + +} // namespace BALM + +using BALM::XTab; + +#endif // X_TAB_H Added: haiku/trunk/headers/libs/alm/YTab.h =================================================================== --- haiku/trunk/headers/libs/alm/YTab.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/alm/YTab.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,37 @@ +#ifndef Y_TAB_H +#define Y_TAB_H + +#include "Variable.h" + +namespace BALM { + +class BALMLayout; + +/** + * Horizontal grid line (y-tab). + */ +class YTab : public Variable { + +protected: + YTab(BALMLayout* ls); + +protected: + /** + * Property signifying if there is a constraint which relates + * this tab to a different tab that is further to the top. + * Only used for reverse engineering. + */ + bool fTopLink; + +public: + friend class Area; + friend class Row; + friend class BALMLayout; + +}; + +} // namespace BALM + +using BALM::YTab; + +#endif // Y_TAB_H Added: haiku/trunk/headers/libs/linprog/Constraint.h =================================================================== --- haiku/trunk/headers/libs/linprog/Constraint.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/Constraint.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,56 @@ +#ifndef CONSTRAINT_H +#define CONSTRAINT_H + +#include "OperatorType.h" + +#include +#include +#include + + +namespace LinearProgramming { + +class LinearSpec; + +/** + * Hard linear constraint, i.e. one that must be satisfied. + * May render a specification infeasible. + */ +class Constraint { + +public: + int32 Index(); + BList* Coeffs(); + BList* Vars(); + virtual void ChangeLeftSide(BList* coeffs, BList* vars); + virtual OperatorType Op(); + virtual void SetOp(OperatorType value); + double RightSide(); + void SetRightSide(double value); + BString ToString(); + virtual ~Constraint(); + +protected: + Constraint(); + +private: + Constraint(LinearSpec* ls, BList* coeffs, BList* vars, + OperatorType op, double rightSide); + +protected: + LinearSpec* fLS; + BList* fCoeffs; + BList* fVars; + OperatorType fOp; + double fRightSide; + +public: + friend class LinearSpec; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::Constraint; + +#endif // CONSTRAINT_H Added: haiku/trunk/headers/libs/linprog/LinearSpec.h =================================================================== --- haiku/trunk/headers/libs/linprog/LinearSpec.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/LinearSpec.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,124 @@ +#ifndef LINEAR_SPEC_H +#define LINEAR_SPEC_H + +#include "OperatorType.h" +#include "ResultType.h" +#include "OptimizationType.h" + +#include "lp_lib.h" + +#include +#include +#include + + +namespace LinearProgramming { + +class Constraint; +class ObjFunctionSummand; +class PenaltyFunction; +class SoftConstraint; +class Variable; + +/** + * Specification of a linear programming problem. + */ +class LinearSpec { + +public: + LinearSpec(); + ~LinearSpec(); + void UpdateObjFunction(); + void SetObjFunction(BList* coeffs, BList* vars); + ObjFunctionSummand* AddObjFunctionSummand(double coeff, Variable* var); + Variable* AddVariable(); + + Constraint* AddConstraint(BList* coeffs, BList* vars, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + OperatorType op, double rightSide); + Constraint* AddConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + double coeff4, Variable* var4, + OperatorType op, double rightSide); + + SoftConstraint* AddSoftConstraint(BList* coeffs, BList* vars, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + double coeff4, Variable* var4, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + + PenaltyFunction* AddPenaltyFunction(Variable* var, BList* xs, BList* gs); + void RemovePresolved(); + ResultType Presolve(); + ResultType Solve(); + void Save(char* fname); + + int32 Columns() const; + void SetColumns(int32 value); + OptimizationType Optimization() const; + void SetOptimization(OptimizationType value); + lprec* LP() const; + void SetLP(lprec* value); + BList* ObjFunctionSummands() const; + void SetObjFunctionSummands(BList* value); + BList* Variables() const; + void SetVariables(BList* value); + BList* Constraints() const; + void SetConstraints(BList* value); + ResultType Result() const; + void SetResult(ResultType value); + double ObjectiveValue() const; + void SetObjectiveValue(double value); + double SolvingTime() const; + void SetSolvingTime(double value); + +protected: + int32 fColumns; + +private: + lprec* fLpPresolved; + OptimizationType fOptimization; + lprec* fLP; + BList* fObjFunctionSummands; + BList* fVariables; + BList* fConstraints; + ResultType fResult; + double fObjectiveValue; + double fSolvingTime; // = Double.Nan + +public: + friend class ObjFunctionSummand; + friend class SoftConstraint; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::LinearSpec; + +#endif // LINEAR_SPEC_H Added: haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h =================================================================== --- haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,39 @@ +#ifndef OBJ_FUNCTION_SUMMAND_H +#define OBJ_FUNCTION_SUMMAND_H + + +namespace LinearProgramming { + +class LinearSpec; +class Variable; + +/** + * A summand of the objective function. + */ +class ObjFunctionSummand { + +public: + double Coeff(); + void SetCoeff(double coeff); + Variable* Var(); + void SetVar(Variable* var); + ~ObjFunctionSummand(); + +protected: + ObjFunctionSummand(LinearSpec* ls, double coeff, Variable* var); + +private: + LinearSpec* fLS; + double fCoeff; + Variable* fVar; + +public: + friend class LinearSpec; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::ObjFunctionSummand; + +#endif // OBJ_FUNCTION_SUMMAND_H Added: haiku/trunk/headers/libs/linprog/OperatorType.h =================================================================== --- haiku/trunk/headers/libs/linprog/OperatorType.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/OperatorType.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,18 @@ +#ifndef OPERATOR_TYPE_H +#define OPERATOR_TYPE_H + + +namespace LinearProgramming { + +/** + * Possible operators for linear constraints. + */ +enum OperatorType { + EQ, LE, GE +}; + +} // namespace LinearProgramming + +using LinearProgramming::OperatorType; + +#endif Added: haiku/trunk/headers/libs/linprog/OptimizationType.h =================================================================== --- haiku/trunk/headers/libs/linprog/OptimizationType.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/OptimizationType.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,18 @@ +#ifndef OPTIMIZATION_TYPE_H +#define OPTIMIZATION_TYPE_H + + +namespace LinearProgramming { + +/** + * The two possibilities for optimizing the objective function. + */ +enum OptimizationType { + MINIMIZE, MAXIMIZE +}; + +} // namespace LinearProgramming + +using LinearProgramming::OptimizationType; + +#endif Added: haiku/trunk/headers/libs/linprog/PenaltyFunction.h =================================================================== --- haiku/trunk/headers/libs/linprog/PenaltyFunction.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/PenaltyFunction.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,43 @@ +#ifndef PENALTY_FUNCTION_H +#define PENALTY_FUNCTION_H + +#include + + +namespace LinearProgramming { + +class LinearSpec; +class Variable; + +/** + * Penalty function. + */ +class PenaltyFunction { + +protected: + PenaltyFunction(LinearSpec* ls, Variable* var, BList* xs, BList* gs); + +public: + ~PenaltyFunction(); + const Variable* Var() const; + const BList* Xs() const; + const BList* Gs() const; + +private: + LinearSpec* fLS; + Variable* fVar; + BList* fXs; // double + BList* fGs; // double + BList* fConstraints; + BList* fObjFunctionSummands; + +public: + friend class LinearSpec; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::PenaltyFunction; + +#endif // PENALTY_FUNCTION_H Added: haiku/trunk/headers/libs/linprog/ResultType.h =================================================================== --- haiku/trunk/headers/libs/linprog/ResultType.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/ResultType.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,20 @@ +#ifndef RESULT_TYPE_H +#define RESULT_TYPE_H + + +namespace LinearProgramming { + +/** + * The possible results of a solving attempt. + */ +enum ResultType { + NOMEMORY = -2, ERROR = -1, OPTIMAL = 0, SUBOPTIMAL = 1, INFEASIBLE = 2, UNBOUNDED = 3, + DEGENERATE = 4, NUMFAILURE = 5, USERABORT = 6, TIMEOUT = 7, PRESOLVED = 9, PROCFAIL = 10, + PROCBREAK = 11, FEASFOUND = 12, NOFEASFOUND = 13 +}; + +} // namespace LinearProgramming + +using LinearProgramming::ResultType; + +#endif Added: haiku/trunk/headers/libs/linprog/SoftConstraint.h =================================================================== --- haiku/trunk/headers/libs/linprog/SoftConstraint.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/SoftConstraint.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,54 @@ +#ifndef SOFT_CONSTRAINT_H +#define SOFT_CONSTRAINT_H + +#include "Constraint.h" + +#include + + +namespace LinearProgramming { + +class LinearSpec; +class ObjFunctionSummand; +class Variable; + +/** + * Soft constraint, i.e. one that does not necessarily have to be satisfied. + * Use this instead of hard constraints to avoid over-constrained specifications. + */ +class SoftConstraint : public Constraint { + +public: + void ChangeLeftSide(BList* coeffs, BList* vars); + OperatorType Op(); + void SetOp(OperatorType value); + double PenaltyNeg(); + void SetPenaltyNeg(double value); + double PenaltyPos(); + void SetPenaltyPos(double value); + //~ string ToString(); + Variable* DNeg() const; + Variable* DPos() const; + ~SoftConstraint(); + +protected: + SoftConstraint(LinearSpec* ls, BList* coeffs, BList* vars, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); + +private: + Variable* fDNeg; + Variable* fDPos; + ObjFunctionSummand* fDNegSummand; + ObjFunctionSummand* fDPosSummand; + +public: + friend class LinearSpec; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::SoftConstraint; + +#endif // SOFT_CONSTRAINT_H Added: haiku/trunk/headers/libs/linprog/Variable.h =================================================================== --- haiku/trunk/headers/libs/linprog/Variable.h 2008-02-06 10:37:19 UTC (rev 23888) +++ haiku/trunk/headers/libs/linprog/Variable.h 2008-02-06 10:51:44 UTC (rev 23889) @@ -0,0 +1,53 @@ +#ifndef VARIABLE_H +#define VARIABLE_H + +#include + + +namespace LinearProgramming { + +class Constraint; +class LinearSpec; + +/** + * Contains minimum and maximum values. + */ +class Variable { + +public: + int32 Index(); + LinearSpec* LS() const; + void SetLS(LinearSpec* value); + double Value() const; + void SetValue(double value); + double Min() const; + void SetMin(double min); + double Max() const; + void SetMax(double max); + void SetRange(double min, double max); + //~ string ToString(); + Constraint* IsEqual(Variable* var); + Constraint* IsSmallerOrEqual(Variable* var); + Constraint* IsGreaterorEqual(Variable* var); + +protected: + Variable(LinearSpec* ls); + ~Variable(); + +private: + LinearSpec* fLS; + double fValue; + double fMin; + double fMax; + +public: + friend class LinearSpec; + friend class SoftConstraint; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::Variable; + +#endif // VARIABLE_H [... truncated: 4831 lines follow ...] From bonefish at mail.berlios.de Wed Feb 6 11:59:34 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 11:59:34 +0100 Subject: [Haiku-commits] r23890 - haiku/trunk/src/apps/aboutsystem Message-ID: <200802061059.m16AxYtc026240@sheep.berlios.de> Author: bonefish Date: 2008-02-06 11:59:34 +0100 (Wed, 06 Feb 2008) New Revision: 23890 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23890&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: * Added James Kim to the list of contributors. * Added temporary copyright entry for lp_solve as a placeholder, until I know what it should say. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-02-06 10:51:44 UTC (rev 23889) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-02-06 10:59:34 UTC (rev 23890) @@ -409,6 +409,7 @@ "Erik Jaesler\n" "Carwyn Jones\n" "Vasilis Kaoutsis\n" + "James Kim\n" "Euan Kirkhope\n" "Jan Kl?tzke\n" "Marcin Konicki\n" @@ -559,6 +560,12 @@ AddCopyrightEntry("Vi IMproved", "Copyright " B_UTF8_COPYRIGHT " Bram Moolenaar et al."); + // lp_solve copyrights + // TODO: Fix! + AddCopyrightEntry("lp_solve", + "Copyright " B_UTF8_COPYRIGHT + " ??? (http://lpsolve.sourceforge.net/)."); + // Build a list of installed applications and show their // long version info. Well-behaved apps usually give // copyright info there. From axeld at mail.berlios.de Wed Feb 6 12:00:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Feb 2008 12:00:27 +0100 Subject: [Haiku-commits] r23891 - haiku/trunk/src/add-ons/kernel/partitioning_systems/session Message-ID: <200802061100.m16B0RlO026442@sheep.berlios.de> Author: axeld Date: 2008-02-06 12:00:26 +0100 (Wed, 06 Feb 2008) New Revision: 23891 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23891&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp Log: Session needs a higher priority than ISO 9660 or the latter might "steal" multi-session CDs. Maybe partitioning systems should give preference over file systems, though. This fixes bug #1634. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp 2008-02-06 10:59:34 UTC (rev 23890) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp 2008-02-06 11:00:26 UTC (rev 23891) @@ -52,7 +52,7 @@ Disc *disc = new Disc(fd); if (disc && disc->InitCheck() == B_OK) { *cookie = static_cast(disc); - result = 0.5; + result = 0.7; } } PRINT(("returning %ld\n", int32(result * 10000))); From axeld at mail.berlios.de Wed Feb 6 12:13:15 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Feb 2008 12:13:15 +0100 Subject: [Haiku-commits] r23892 - haiku/trunk/src/system/kernel/fs Message-ID: <200802061113.m16BDFF0027214@sheep.berlios.de> Author: axeld Date: 2008-02-06 12:13:14 +0100 (Wed, 06 Feb 2008) New Revision: 23892 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23892&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: * devfs now uses the driver's name instead of its node_ref to see if it already knows this driver. * This should also allow to have a driver in home/config/add-ons/... overlays a driver with the same name in system/add-ons/... * This should also fix bug #1750. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-06 11:00:26 UTC (rev 23891) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-06 11:13:14 UTC (rev 23892) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -125,6 +125,7 @@ struct driver_entry { driver_entry *next; const char *path; + const char *name; dev_t device; ino_t node; time_t last_modified; @@ -163,12 +164,12 @@ driver_entry_hash(void *_driver, const void *_key, uint32 range) { driver_entry *driver = (driver_entry *)_driver; - const ino_t *key = (const ino_t *)_key; + const char *key = (const char *)_key; if (driver != NULL) - return driver->node % range; + return hash_hash_string(driver->name) % range; - return (uint64)*key % range; + return hash_hash_string(key) % range; } @@ -176,12 +177,9 @@ driver_entry_compare(void *_driver, const void *_key) { driver_entry *driver = (driver_entry *)_driver; - const ino_t *key = (const ino_t *)_key; + const char *key = (const char *)_key; - if (driver->node == *key) - return 0; - - return -1; + return strcmp(driver->name, key); } @@ -202,13 +200,6 @@ return image; } - // for prettier debug output - const char *name = strrchr(driver->path, '/'); - if (name == NULL) - name = driver->path; - else - name++; - // For a valid device driver the following exports are required driver->api_version = &sDefaultApiVersion; @@ -219,23 +210,24 @@ #error Add checks here for new vs old api version! #endif if (*driver->api_version > B_CUR_DRIVER_API_VERSION) { - dprintf("%s: api_version %ld not handled\n", name, *driver->api_version); + dprintf("%s: api_version %ld not handled\n", driver->name, + *driver->api_version); status = B_BAD_VALUE; goto error1; } if (*driver->api_version < 1) { - dprintf("%s: api_version invalid\n", name); + dprintf("%s: api_version invalid\n", driver->name); status = B_BAD_VALUE; goto error1; } } else - dprintf("%s: api_version missing\n", name); + dprintf("%s: api_version missing\n", driver->name); if (get_image_symbol(image, "publish_devices", B_SYMBOL_TYPE_TEXT, (void **)&driver->publish_devices) != B_OK || get_image_symbol(image, "find_device", B_SYMBOL_TYPE_TEXT, (void **)&driver->find_device) != B_OK) { - dprintf("%s: mandatory driver symbol(s) missing!\n", name); + dprintf("%s: mandatory driver symbol(s) missing!\n", driver->name); status = B_BAD_VALUE; goto error1; } @@ -245,7 +237,8 @@ if (get_image_symbol(image, "init_hardware", B_SYMBOL_TYPE_TEXT, (void **)&init_hardware) == B_OK && (status = init_hardware()) != B_OK) { - dprintf("%s: init_hardware() failed: %s\n", name, strerror(status)); + dprintf("%s: init_hardware() failed: %s\n", driver->name, + strerror(status)); status = ENXIO; goto error1; } @@ -253,7 +246,8 @@ if (get_image_symbol(image, "init_driver", B_SYMBOL_TYPE_TEXT, (void **)&init_driver) == B_OK && (status = init_driver()) != B_OK) { - dprintf("%s: init_driver() failed: %s\n", name, strerror(status)); + dprintf("%s: init_driver() failed: %s\n", driver->name, + strerror(status)); status = ENXIO; goto error2; } @@ -272,7 +266,7 @@ // we keep the driver loaded if it exports at least a single interface devicePaths = driver->publish_devices(); if (devicePaths == NULL) { - dprintf("%s: publish_devices() returned NULL.\n", name); + dprintf("%s: publish_devices() returned NULL.\n", driver->name); status = ENXIO; goto error3; } @@ -332,6 +326,17 @@ } +static const char * +get_leaf(const char *path) +{ + const char *name = strrchr(path, '/'); + if (name == NULL) + return path; + + return name + 1; +} + + static status_t add_driver(const char *path, image_id image) { @@ -339,12 +344,11 @@ struct stat stat; if (image >= 0) { - // TODO: Unfortunately only the node ID is the key for the hash table. // The image ID should be a small number and hopefully the boot FS // doesn't use small negative values -- if it is inode based, we should // be relatively safe. stat.st_dev = -1; - stat.st_ino = -image; + stat.st_ino = -1; } else { if (::stat(path, &stat) != 0) return errno; @@ -353,10 +357,11 @@ RecursiveLocker locker(&sDeviceFileSystem->lock); driver_entry *driver = (driver_entry *)hash_lookup( - sDeviceFileSystem->driver_hash, &stat.st_ino); + sDeviceFileSystem->driver_hash, get_leaf(path)); if (driver != NULL) { // we know this driver - // ToDo: test for changes here? Although node monitoring should be enough. + // TODO: test for changes here and/or via node monitoring and reload + // the driver if necessary if (driver->image < B_OK) return driver->image; @@ -375,6 +380,7 @@ return B_NO_MEMORY; } + driver->name = get_leaf(driver->path); driver->device = stat.st_dev; driver->node = stat.st_ino; driver->image = image; From bonefish at mail.berlios.de Wed Feb 6 12:19:59 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 12:19:59 +0100 Subject: [Haiku-commits] r23893 - haiku/trunk/src/tests/libs/alm Message-ID: <200802061119.m16BJxmW027513@sheep.berlios.de> Author: bonefish Date: 2008-02-06 12:19:59 +0100 (Wed, 06 Feb 2008) New Revision: 23893 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23893&view=rev Modified: haiku/trunk/src/tests/libs/alm/Jamfile Log: Renamed the ALM test programs to be less likely to clash with others. Modified: haiku/trunk/src/tests/libs/alm/Jamfile =================================================================== --- haiku/trunk/src/tests/libs/alm/Jamfile 2008-02-06 11:13:14 UTC (rev 23892) +++ haiku/trunk/src/tests/libs/alm/Jamfile 2008-02-06 11:19:59 UTC (rev 23893) @@ -4,19 +4,19 @@ UseLibraryHeaders lp_solve linprog alm ; -Application table_test : +Application ALMTableTest : TableTest.cpp : be liblpsolve55.so liblinprog.so libalm.so ; -Application test1 : +Application ALMTest1 : Test1.cpp : be liblpsolve55.so be liblinprog.so libalm.so ; -Application test2 : +Application ALMTest2 : Test2.cpp : be liblpsolve55.so be liblinprog.so libalm.so From ingo_weinhold at gmx.de Wed Feb 6 12:32:32 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Feb 2008 12:32:32 +0100 Subject: [Haiku-commits] r23891 - haiku/trunk/src/add-ons/kernel/partitioning_systems/session In-Reply-To: <200802061100.m16B0RlO026442@sheep.berlios.de> References: <200802061100.m16B0RlO026442@sheep.berlios.de> Message-ID: <20080206123232.672.2@knochen-vm.nameserver> On 2008-02-06 at 12:00:27 [+0100], axeld at BerliOS wrote: > Author: axeld > Date: 2008-02-06 12:00:26 +0100 (Wed, 06 Feb 2008) > New Revision: 23891 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23891&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp > Log: > Session needs a higher priority than ISO 9660 or the latter might "steal" > multi-session CDs. Maybe partitioning systems should give preference over > file systems, though. That would be a little problematic, since e.g. BFS partitions seem to have the PTS signature and might thus potentially be recognized as intel partitioning system. CU, Ingo From ingo_weinhold at gmx.de Wed Feb 6 12:40:33 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Feb 2008 12:40:33 +0100 Subject: [Haiku-commits] r23892 - haiku/trunk/src/system/kernel/fs In-Reply-To: <200802061113.m16BDFF0027214@sheep.berlios.de> References: <200802061113.m16BDFF0027214@sheep.berlios.de> Message-ID: <20080206124033.725.3@knochen-vm.nameserver> On 2008-02-06 at 12:13:15 [+0100], axeld at BerliOS wrote: > Author: axeld > Date: 2008-02-06 12:13:14 +0100 (Wed, 06 Feb 2008) > New Revision: 23892 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23892&view=rev > > Modified: > haiku/trunk/src/system/kernel/fs/devfs.cpp > Log: > * devfs now uses the driver's name instead of its node_ref to see if it > already knows this driver. > * This should also allow to have a driver in home/config/add-ons/... > overlays > a driver with the same name in system/add-ons/... > * This should also fix bug #1750. It does indeed. Thanks! Now, if you would also fix the problem that the hard disks don't work when booting via PXE, you'd be my personal hero for today (maybe even for this week). :-) CU, Ingo From axeld at mail.berlios.de Wed Feb 6 12:46:45 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Feb 2008 12:46:45 +0100 Subject: [Haiku-commits] r23894 - haiku/trunk/src/system/kernel/disk_device_manager Message-ID: <200802061146.m16Bkjds024499@sheep.berlios.de> Author: axeld Date: 2008-02-06 12:46:44 +0100 (Wed, 06 Feb 2008) New Revision: 23894 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23894&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp Log: * When removing a media, only the device was unmounted if needed, not its child partitions. Not sure if this is the right place, Ingo might want to review that one. * This fixes unmounting sessions of a multi-session CD, ie. the BeOS CD (it currently panics when trying to access a device that's not there anymore - for debugging only, of course :-) Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2008-02-06 11:19:59 UTC (rev 23893) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2008-02-06 11:46:44 UTC (rev 23894) @@ -131,6 +131,7 @@ KPartition::PrepareForRemoval() { bool result = RemoveAllChildren(); + UninitializeContents(); UnpublishDevice(); if (ParentDiskSystem()) ParentDiskSystem()->FreeCookie(this); From axeld at pinc-software.de Wed Feb 6 12:47:52 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 06 Feb 2008 12:47:52 +0100 CET Subject: [Haiku-commits] r23891 - haiku/trunk/src/add-ons/kernel/partitioning_systems/session In-Reply-To: <20080206123232.672.2@knochen-vm.nameserver> Message-ID: <9089174924-BeMail@zon> Ingo Weinhold wrote: > On 2008-02-06 at 12:00:27 [+0100], axeld at BerliOS < > axeld at mail.berlios.de> > wrote: > > Author: axeld > > Date: 2008-02-06 12:00:26 +0100 (Wed, 06 Feb 2008) > > New Revision: 23891 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23891&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/kernel/partitioning_systems/session/ > > session.cpp > > Log: > > Session needs a higher priority than ISO 9660 or the latter might > > "steal" > > multi-session CDs. Maybe partitioning systems should give > > preference over > > file systems, though. > That would be a little problematic, since e.g. BFS partitions seem to > have > the PTS signature and might thus potentially be recognized as intel > partitioning system. True enough, but at least it would contain no parititons, so it could handle this case specially. Anyway, if no other problems pop up, we could just not think about it right now ;-) Bye, Axel. From ingo_weinhold at gmx.de Wed Feb 6 13:00:37 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Feb 2008 13:00:37 +0100 Subject: [Haiku-commits] r23894 - haiku/trunk/src/system/kernel/disk_device_manager In-Reply-To: <200802061146.m16Bkjds024499@sheep.berlios.de> References: <200802061146.m16Bkjds024499@sheep.berlios.de> Message-ID: <20080206130037.509.1@knochen-vm.nameserver> On 2008-02-06 at 12:46:45 [+0100], axeld at BerliOS wrote: > Author: axeld > Date: 2008-02-06 12:46:44 +0100 (Wed, 06 Feb 2008) > New Revision: 23894 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23894&view=rev > > Modified: > haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp > Log: > * When removing a media, only the device was unmounted if needed, not its > child partitions. > Not sure if this is the right place, Ingo might want to review that one. RemoveChild() would be an alternative place, but PrepareForRemoval() is even better, I think. CU, Ingo From axeld at pinc-software.de Wed Feb 6 13:30:15 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 06 Feb 2008 13:30:15 +0100 CET Subject: [Haiku-commits] r23894 - haiku/trunk/src/system/kernel/disk_device_manager In-Reply-To: <20080206130037.509.1@knochen-vm.nameserver> Message-ID: <11632032229-BeMail@zon> Ingo Weinhold wrote: > > Modified: > > haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp > > Log: > > * When removing a media, only the device was unmounted if needed, > > not its > > child partitions. > > Not sure if this is the right place, Ingo might want to review > > that one. > RemoveChild() would be an alternative place, but PrepareForRemoval() > is even > better, I think. Thanks! Bye, Axel. From bonefish at mail.berlios.de Wed Feb 6 14:22:15 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 6 Feb 2008 14:22:15 +0100 Subject: [Haiku-commits] r23895 - haiku/trunk/build/jam Message-ID: <200802061322.m16DMFej025160@sheep.berlios.de> Author: bonefish Date: 2008-02-06 14:22:14 +0100 (Wed, 06 Feb 2008) New Revision: 23895 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23895&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Beginnings of an optional "Development" package. Currently only the glue code and the library symlinks are installed. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-06 11:46:44 UTC (rev 23894) +++ haiku/trunk/build/jam/HaikuImage 2008-02-06 13:22:14 UTC (rev 23895) @@ -61,7 +61,7 @@ $(X86_ONLY)GLDirectMode $(X86_ONLY)GLTeapot Mandelbrot PictureTest Playground Pulse Sudoku ; -BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so +BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so @@ -176,14 +176,18 @@ AddFilesToHaikuImage beos system : kernel_$(TARGET_ARCH) ; # libs -AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIB) ; +AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIBS) ; + # libnetwork.so replaces quite a few libraries -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libsocket.so ; -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libbind.so ; -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libnet.so ; -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libnetapi.so ; -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libbnetapi.so ; -# libGL.so have GLUT built-in +BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES + = libsocket.so libbind.so libnet.so libnetapi.so libbnetapi.so ; + +local lib ; +for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { + AddSymlinkToHaikuImage beos system lib : libnetwork.so : $(lib) ; +} + +# libGL.so has GLUT built-in if $(TARGET_ARCH) = x86 { AddSymlinkToHaikuImage beos system lib : $(X86_ONLY)libGL.so : libglut.so ; } @@ -473,6 +477,21 @@ #pragma mark - Optional Packages +# Development +if [ IsOptionalHaikuImagePackageAdded Development ] + && $(TARGET_ARCH) = x86 { + # glue code + AddFilesToHaikuImage develop lib x86 + : crti.o crtn.o + init_term_dyn.o start_dyn.o ; + + # library symlinks + local lib ; + for lib in $(BEOS_SYSTEM_LIBS) $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { + AddSymlinkToHaikuImage develop lib x86 : /system/lib/$(lib:BS) ; + } +} + # Vision if [ IsOptionalHaikuImagePackageAdded Vision ] { InstallOptionalHaikuImagePackage Vision From niels.reedijk at gmail.com Wed Feb 6 14:47:58 2008 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Wed, 6 Feb 2008 14:47:58 +0100 Subject: [Haiku-commits] r23895 - haiku/trunk/build/jam In-Reply-To: <200802061322.m16DMFej025160@sheep.berlios.de> References: <200802061322.m16DMFej025160@sheep.berlios.de> Message-ID: <507d86c0802060547j2b425644k2da66eab3eb0f1cf@mail.gmail.com> Ingo, I managed to compile gcc 4 on linux for haiku. I needed to make two minor changes. As i still don't have any internet access here, i cannot share them right now. How do you want to persue this? Do you want to dive in yourself or together? Niels On 2/6/08, bonefish at BerliOS wrote: > Author: bonefish > Date: 2008-02-06 14:22:14 +0100 (Wed, 06 Feb 2008) > New Revision: 23895 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23895&view=rev > > Modified: > haiku/trunk/build/jam/HaikuImage > Log: > Beginnings of an optional "Development" package. Currently only the glue > code and the library symlinks are installed. > > > Modified: haiku/trunk/build/jam/HaikuImage > =================================================================== > --- haiku/trunk/build/jam/HaikuImage 2008-02-06 11:46:44 UTC (rev 23894) > +++ haiku/trunk/build/jam/HaikuImage 2008-02-06 13:22:14 UTC (rev 23895) > @@ -61,7 +61,7 @@ > $(X86_ONLY)GLDirectMode $(X86_ONLY)GLTeapot Mandelbrot PictureTest > Playground Pulse Sudoku > ; > -BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so > +BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so > libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so > libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so > libdevice.so libgame.so libscreensaver.so libroot.so > @@ -176,14 +176,18 @@ > AddFilesToHaikuImage beos system : kernel_$(TARGET_ARCH) ; > > # libs > -AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIB) ; > +AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIBS) ; > + > # libnetwork.so replaces quite a few libraries > -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libsocket.so ; > -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libbind.so ; > -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libnet.so ; > -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libnetapi.so ; > -AddSymlinkToHaikuImage beos system lib : libnetwork.so : libbnetapi.so ; > -# libGL.so have GLUT built-in > +BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES > + = libsocket.so libbind.so libnet.so libnetapi.so libbnetapi.so ; > + > +local lib ; > +for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { > + AddSymlinkToHaikuImage beos system lib : libnetwork.so : $(lib) ; > +} > + > +# libGL.so has GLUT built-in > if $(TARGET_ARCH) = x86 { > AddSymlinkToHaikuImage beos system lib : $(X86_ONLY)libGL.so : libglut.so > ; > } > @@ -473,6 +477,21 @@ > #pragma mark - Optional Packages > > > +# Development > +if [ IsOptionalHaikuImagePackageAdded Development ] > + && $(TARGET_ARCH) = x86 { > + # glue code > + AddFilesToHaikuImage develop lib x86 > + : crti.o crtn.o > + init_term_dyn.o start_dyn.o ; > + > + # library symlinks > + local lib ; > + for lib in $(BEOS_SYSTEM_LIBS) $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { > + AddSymlinkToHaikuImage develop lib x86 : /system/lib/$(lib:BS) ; > + } > +} > + > # Vision > if [ IsOptionalHaikuImagePackageAdded Vision ] { > InstallOptionalHaikuImagePackage Vision > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From ingo_weinhold at gmx.de Wed Feb 6 15:31:40 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Feb 2008 15:31:40 +0100 Subject: [Haiku-commits] r23895 - haiku/trunk/build/jam In-Reply-To: <507d86c0802060547j2b425644k2da66eab3eb0f1cf@mail.gmail.com> References: <200802061322.m16DMFej025160@sheep.berlios.de> <507d86c0802060547j2b425644k2da66eab3eb0f1cf@mail.gmail.com> Message-ID: <20080206153140.403.1@knochen-vm.1202304393.fake> On 2008-02-06 at 14:47:58 [+0100], Niels Reedijk wrote: > Ingo, I managed to compile gcc 4 on linux for haiku. I needed to make > two minor changes. As i still don't have any internet access here, i > cannot share them right now. How do you want to persue this? Do you > want to dive in yourself or together? Niels Just send me the patch, when you have internet access again. CU, Ingo From niels.reedijk at gmail.com Wed Feb 6 16:00:13 2008 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Wed, 6 Feb 2008 16:00:13 +0100 Subject: [Haiku-commits] r23895 - haiku/trunk/build/jam In-Reply-To: <20080206153140.403.1@knochen-vm.1202304393.fake> References: <200802061322.m16DMFej025160@sheep.berlios.de> <507d86c0802060547j2b425644k2da66eab3eb0f1cf@mail.gmail.com> <20080206153140.403.1@knochen-vm.1202304393.fake> Message-ID: <507d86c0802060700p95bf703j73051c1331548538@mail.gmail.com> I will. By the way: you are aware of the legacy gcc patch and build script right? You can find it in trac. Shall i leave it to you to properly integrate it into the build then? On 2/6/08, Ingo Weinhold wrote: > > On 2008-02-06 at 14:47:58 [+0100], Niels Reedijk > wrote: > > Ingo, I managed to compile gcc 4 on linux for haiku. I needed to make > > two minor changes. As i still don't have any internet access here, i > > cannot share them right now. How do you want to persue this? Do you > > want to dive in yourself or together? Niels > > Just send me the patch, when you have internet access again. > > CU, Ingo > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From mmlr at mlotz.ch Wed Feb 6 16:40:52 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Wed, 6 Feb 2008 16:40:52 +0100 Subject: [Haiku-commits] r23881 - haiku/trunk/src/add-ons/kernel/busses/agp_gart In-Reply-To: <200802052215.m15MFGKU011873@sheep.berlios.de> References: <200802052215.m15MFGKU011873@sheep.berlios.de> Message-ID: <20080206153659.M20480@mlotz.ch> On Tue, 5 Feb 2008 23:15:16 +0100, axeld at BerliOS wrote > Author: axeld > Date: 2008-02-05 23:15:15 +0100 (Tue, 05 Feb 2008) > New Revision: 23881 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23881&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp > Log: > * Added bridge device ID for i865. > * Added other IDs from the graphics driver, but I need to look up > their bridge IDs before actually adding them. I can provide a listdev of my laptop that has a i965GM if this is of any use to you. The driver did work more or less when manually adding the id and disabling all acceleration. I'd love to get it to that state again as with the vesa mode I cannot use the native 1280x800 resolution. Regards Michael From ingo_weinhold at gmx.de Wed Feb 6 17:18:10 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Feb 2008 17:18:10 +0100 Subject: [Haiku-commits] r23895 - haiku/trunk/build/jam In-Reply-To: <507d86c0802060700p95bf703j73051c1331548538@mail.gmail.com> References: <200802061322.m16DMFej025160@sheep.berlios.de> <507d86c0802060547j2b425644k2da66eab3eb0f1cf@mail.gmail.com> <20080206153140.403.1@knochen-vm.1202304393.fake> <507d86c0802060700p95bf703j73051c1331548538@mail.gmail.com> Message-ID: <20080206171810.685.3@knochen-vm.1202304393.fake> On 2008-02-06 at 16:00:13 [+0100], Niels Reedijk wrote: > I will. By the way: you are aware of the legacy gcc patch and build > script right? I've seen them, but haven't had a closer look yet. > You can find it in trac. Shall i leave it to you to > properly integrate it into the build then? I'm yet uncertain to what degree I'd want to integrate building the native Haiku compiler into the build. Providing a script to cross-build it is OK, but I think, a downloadable package (automatically installed as part of the optional Development package) will be preferred by everyone who doesn't want to tinker with gcc itself. CU, Ingo From axeld at pinc-software.de Wed Feb 6 17:41:49 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 06 Feb 2008 17:41:49 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23881_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/busses/agp=5Fgart?= In-Reply-To: <20080206153659.M20480@mlotz.ch> Message-ID: <26726470887-BeMail@zon> "Michael Lotz" wrote: > On Tue, 5 Feb 2008 23:15:16 +0100, axeld at BerliOS wrote > > Author: axeld > > Date: 2008-02-05 23:15:15 +0100 (Tue, 05 Feb 2008) > > New Revision: 23881 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23881&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/kernel/busses/agp_gart/intel_gart.cpp > > Log: > > * Added bridge device ID for i865. > > * Added other IDs from the graphics driver, but I need to look up > > their bridge IDs before actually adding them. > I can provide a listdev of my laptop that has a i965GM if this is of > any use > to you. The driver did work more or less when manually adding the id > and > disabling all acceleration. I'd love to get it to that state again as > with the > vesa mode I cannot use the native 1280x800 resolution. Feel free to enable that driver again - all you have to is to add the bridge ID (probably 0x29a0) and the driver should work as before, eventually even with overlay (at least it works on G33, and even though the X driver does not enable real overlay with the i965, I don't see anything in the specs that would explain that). After skiing, I will rebuild my i965 system to do further tests with that. Bye, Axel. From axeld at mail.berlios.de Wed Feb 6 18:11:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Feb 2008 18:11:03 +0100 Subject: [Haiku-commits] r23896 - in haiku/trunk: headers/posix src/system/libroot/posix/stdlib Message-ID: <200802061711.m16HB3Vo023446@sheep.berlios.de> Author: axeld Date: 2008-02-06 18:11:02 +0100 (Wed, 06 Feb 2008) New Revision: 23896 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23896&view=rev Added: haiku/trunk/src/system/libroot/posix/stdlib/gcvt.c Modified: haiku/trunk/headers/posix/stdlib.h haiku/trunk/src/system/libroot/posix/stdlib/Jamfile Log: * Added gcvt() implementation - this fixes bug #1757. * Added gcvt(), ecvt(), and fcvt() prototypes to stdlib.h - they are all marked legacy, but are still part of the POSIX standard, so we might want to implement them if the need arises. Modified: haiku/trunk/headers/posix/stdlib.h =================================================================== --- haiku/trunk/headers/posix/stdlib.h 2008-02-06 13:22:14 UTC (rev 23895) +++ haiku/trunk/headers/posix/stdlib.h 2008-02-06 17:11:02 UTC (rev 23896) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku Inc. All Rights Reserved. + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STDLIB_H_ @@ -66,6 +66,11 @@ extern char *mktemp(char *name); extern int mkstemp(char *templat); +extern char *ecvt(double value, int digits, int *_decimalPoint, int *_sign); +extern char *fcvt(double value, int precision, int *_decimalPoint, + int *_sign); +extern char *gcvt(double value, int digits, char *buffer); + /* environment variables */ extern char **environ; extern char *getenv(const char *name); @@ -131,11 +136,16 @@ extern void *bsearch(const void *key, const void *base, size_t numElements, size_t sizeOfElement, _compare_function); -extern int heapsort(void *base, size_t numElements, size_t sizeOfElement, _compare_function); -extern int mergesort(void *base, size_t numElements, size_t sizeOfElement, _compare_function); -extern void qsort(void *base, size_t numElements, size_t sizeOfElement, _compare_function); -extern int radixsort(u_char const **base, int numElements, u_char const *table, u_int endByte); -extern int sradixsort(u_char const **base, int numElements, u_char const *table, u_int endByte); +extern int heapsort(void *base, size_t numElements, size_t sizeOfElement, + _compare_function); +extern int mergesort(void *base, size_t numElements, size_t sizeOfElement, + _compare_function); +extern void qsort(void *base, size_t numElements, size_t sizeOfElement, + _compare_function); +extern int radixsort(u_char const **base, int numElements, + u_char const *table, u_int endByte); +extern int sradixsort(u_char const **base, int numElements, + u_char const *table, u_int endByte); /* misc math functions */ extern int abs(int number); Modified: haiku/trunk/src/system/libroot/posix/stdlib/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/Jamfile 2008-02-06 13:22:14 UTC (rev 23895) +++ haiku/trunk/src/system/libroot/posix/stdlib/Jamfile 2008-02-06 17:11:02 UTC (rev 23896) @@ -12,6 +12,7 @@ div.c env.c exit.c + gcvt.c heapsort.c merge.c mktemp.c Added: haiku/trunk/src/system/libroot/posix/stdlib/gcvt.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/gcvt.c 2008-02-06 13:22:14 UTC (rev 23895) +++ haiku/trunk/src/system/libroot/posix/stdlib/gcvt.c 2008-02-06 17:11:02 UTC (rev 23896) @@ -0,0 +1,18 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + + +char * +gcvt(double value, int digits, char *buffer) +{ + sprintf(buffer, "%.*g", digits, value); + return buffer; +} + + +// TODO: eventually add ecvt(), and fcvt() as well, if needed. From axeld at pinc-software.de Wed Feb 6 18:14:48 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 06 Feb 2008 18:14:48 +0100 CET Subject: [Haiku-commits] r23892 - haiku/trunk/src/system/kernel/fs In-Reply-To: <20080206124033.725.3@knochen-vm.nameserver> Message-ID: <28705759008-BeMail@zon> Ingo Weinhold wrote: > > * This should also fix bug #1750. > It does indeed. Thanks! Now, if you would also fix the problem that > the hard > disks don't work when booting via PXE, you'd be my personal hero for > today > (maybe even for this week). :-) No time right now :-) It might just be a problem of the device manager - and since we wanted to redesign/rewrite that one, anyway, eventually the problem will go away automatically, too, then... Bye, Axel. From oruizdorantes at mail.berlios.de Wed Feb 6 18:57:30 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Wed, 6 Feb 2008 18:57:30 +0100 Subject: [Haiku-commits] r23897 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200802061757.m16HvUav000513@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-06 18:57:29 +0100 (Wed, 06 Feb 2008) New Revision: 23897 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23897&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h Log: Added macros to parse port code, cointaining the event Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-06 17:11:02 UTC (rev 23896) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-06 17:57:29 UTC (rev 23897) @@ -85,6 +85,9 @@ #define GET_HCI_ID (1<<3) #define PACK_PORTCODE(type,hid,data) ((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF)) +#define GET_PORTCODE_TYPE(code) ((code&0xFF000000)>>24) +#define GET_PORTCODE_HID(code) ((code&0x00FF0000)>>16) +#define GET_PORTCODE_DATA(code) ((code&0x0000FFFF)) /* Port drivers can use to send information (1 for all for at moment refer to ioctl GET_NOTIFICATION_PORT)*/ From oruizdorantes at mail.berlios.de Wed Feb 6 19:00:05 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Wed, 6 Feb 2008 19:00:05 +0100 Subject: [Haiku-commits] r23898 - haiku/trunk/headers/os/bluetooth Message-ID: <200802061800.m16I051E003565@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-06 19:00:04 +0100 (Wed, 06 Feb 2008) New Revision: 23898 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23898&view=rev Added: haiku/trunk/headers/os/bluetooth/bluetooth_error.h Log: Add bluetooth error codes according 2.1+EDR official specs Added: haiku/trunk/headers/os/bluetooth/bluetooth_error.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth_error.h 2008-02-06 17:57:29 UTC (rev 23897) +++ haiku/trunk/headers/os/bluetooth/bluetooth_error.h 2008-02-06 18:00:04 UTC (rev 23898) @@ -0,0 +1,74 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + +#ifndef _BLUETOOTH_ERROR_H +#define _BLUETOOTH_ERROR_H + +#include + + +#define BT_OK B_OK +#define BT_ERROR BT_UNSPECIFIED_ERROR + +/* Official error code for Bluetooth V2.1 + EDR */ +#define BT_UNKNOWN_COMMAND 0x01 +#define BT_NO_CONNECTION 0x02 +#define BT_HARDWARE_FAILURE 0x03 +#define BT_PAGE_TIMEOUT 0x04 +#define BT_AUTHENTICATION_FAILURE 0x05 +#define BT_PIN_OR_KEY_MISSING 0x06 +#define BT_MEMORY_FULL 0x07 +#define BT_CONNECTION_TIMEOUT 0x08 +#define BT_MAX_NUMBER_OF_CONNECTIONS 0x09 +#define BT_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a +#define BT_ACL_CONNECTION_EXISTS 0x0b +#define BT_COMMAND_DISALLOWED 0x0c +#define BT_REJECTED_LIMITED_RESOURCES 0x0d +#define BT_REJECTED_SECURITY 0x0e +#define BT_REJECTED_PERSONAL 0x0f +#define BT_HOST_TIMEOUT 0x10 +#define BT_UNSUPPORTED_FEATURE 0x11 +#define BT_INVALID_PARAMETERS 0x12 +#define BT_OE_USER_ENDED_CONNECTION 0x13 +#define BT_OE_LOW_RESOURCES 0x14 +#define BT_OE_POWER_OFF 0x15 +#define BT_CONNECTION_TERMINATED 0x16 +#define BT_REPEATED_ATTEMPTS 0x17 +#define BT_PAIRING_NOT_ALLOWED 0x18 +#define BT_UNKNOWN_LMP_PDU 0x19 +#define BT_UNSUPPORTED_REMOTE_FEATURE 0x1a +#define BT_SCO_OFFSET_REJECTED 0x1b +#define BT_SCO_INTERVAL_REJECTED 0x1c +#define BT_AIR_MODE_REJECTED 0x1d +#define BT_INVALID_LMP_PARAMETERS 0x1e +#define BT_UNSPECIFIED_ERROR 0x1f +#define BT_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20 +#define BT_ROLE_CHANGE_NOT_ALLOWED 0x21 +#define BT_LMP_RESPONSE_TIMEOUT 0x22 +#define BT_LMP_ERROR_TRANSACTION_COLLISION 0x23 +#define BT_LMP_PDU_NOT_ALLOWED 0x24 +#define BT_ENCRYPTION_MODE_NOT_ACCEPTED 0x25 +#define BT_UNIT_LINK_KEY_USED 0x26 +#define BT_QOS_NOT_SUPPORTED 0x27 +#define BT_INSTANT_PASSED 0x28 +#define BT_PAIRING_NOT_SUPPORTED 0x29 +#define BT_TRANSACTION_COLLISION 0x2a +#define BT_QOS_UNACCEPTABLE_PARAMETER 0x2c +#define BT_QOS_REJECTED 0x2d +#define BT_CLASSIFICATION_NOT_SUPPORTED 0x2e +#define BT_INSUFFICIENT_SECURITY 0x2f +#define BT_PARAMETER_OUT_OF_RANGE 0x30 +#define BT_ROLE_SWITCH_PENDING 0x32 +#define BT_SLOT_VIOLATION 0x34 +#define BT_ROLE_SWITCH_FAILED 0x35 + +#define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 +#define SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37 +#define HOST_BUSY_PAIRING 0x38 + + +#endif From axeld at mail.berlios.de Wed Feb 6 19:15:43 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Feb 2008 19:15:43 +0100 Subject: [Haiku-commits] r23899 - haiku/trunk/build/jam Message-ID: <200802061815.m16IFhP1016960@sheep.berlios.de> Author: axeld Date: 2008-02-06 19:15:43 +0100 (Wed, 06 Feb 2008) New Revision: 23899 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23899&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Added RAWTranslator to the build. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-06 18:00:04 UTC (rev 23898) +++ haiku/trunk/build/jam/HaikuImage 2008-02-06 18:15:43 UTC (rev 23899) @@ -87,7 +87,7 @@ BEOS_ADD_ONS_TRANSLATORS = BMPTranslator GIFTranslator JPEGTranslator JPEG2000Translator TIFFTranslator PNGTranslator PPMTranslator RTF-Translator SGITranslator STXTTranslator TGATranslator - WonderBrushTranslator + WonderBrushTranslator RAWTranslator ; BEOS_ADD_ONS_MEDIA = mixer.media_addon hmulti_audio.media_addon tone_producer_demo.media_addon From marcusoverhagen at mail.berlios.de Wed Feb 6 23:08:25 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 6 Feb 2008 23:08:25 +0100 Subject: [Haiku-commits] r23900 - haiku/trunk/src/kits/media Message-ID: <200802062208.m16M8P6b031971@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-06 23:08:25 +0100 (Wed, 06 Feb 2008) New Revision: 23900 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23900&view=rev Modified: haiku/trunk/src/kits/media/DataExchange.cpp haiku/trunk/src/kits/media/TimeSource.cpp Log: Removed the no longer needed debug code. Modified: haiku/trunk/src/kits/media/DataExchange.cpp =================================================================== --- haiku/trunk/src/kits/media/DataExchange.cpp 2008-02-06 18:15:43 UTC (rev 23899) +++ haiku/trunk/src/kits/media/DataExchange.cpp 2008-02-06 22:08:25 UTC (rev 23900) @@ -1,5 +1,5 @@ /* - * Copyright 2002, Marcus Overhagen. All rights reserved. + * Copyright 2002-2007, Marcus Overhagen. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -74,13 +74,6 @@ } -static void check(int code) -{ - static int rep = 0; - if(code == 0x204 && rep++ == 200) - debugger("scheisse!"); -} - status_t request_data::SendReply(status_t result, reply_data *reply, int replysize) const { @@ -145,7 +138,7 @@ status_t SendToPort(port_id sendport, int32 msgcode, command_data *msg, int size) { status_t rv; - check(msgcode); + rv = write_port_etc(sendport, msgcode, msg, size, B_RELATIVE_TIMEOUT, TIMEOUT); if (rv != B_OK) { ERROR("SendToPort: write_port failed, msgcode 0x%lx, port %ld, error %#lx (%s)\n", msgcode, sendport, rv, strerror(rv)); @@ -158,7 +151,7 @@ } else { return rv; } - check(msgcode); + rv = write_port_etc(sendport, msgcode, msg, size, B_RELATIVE_TIMEOUT, TIMEOUT); if (rv != B_OK) { ERROR("SendToPort: retrying write_port failed, msgcode 0x%lx, port %ld, error %#lx (%s)\n", msgcode, sendport, rv, strerror(rv)); @@ -176,7 +169,6 @@ request->reply_port = _PortPool->GetPort(); - check(msgcode); rv = write_port_etc(requestport, msgcode, request, requestsize, B_RELATIVE_TIMEOUT, TIMEOUT); if (rv != B_OK) { @@ -191,7 +183,7 @@ _PortPool->PutPort(request->reply_port); return rv; } - check(msgcode); + rv = write_port_etc(requestport, msgcode, request, requestsize, B_RELATIVE_TIMEOUT, TIMEOUT); if (rv != B_OK) { ERROR("QueryPort: retrying write_port failed, msgcode 0x%lx, port %ld, error %#lx (%s)\n", msgcode, requestport, rv, strerror(rv)); Modified: haiku/trunk/src/kits/media/TimeSource.cpp =================================================================== --- haiku/trunk/src/kits/media/TimeSource.cpp 2008-02-06 18:15:43 UTC (rev 23899) +++ haiku/trunk/src/kits/media/TimeSource.cpp 2008-02-06 22:08:25 UTC (rev 23900) @@ -477,8 +477,6 @@ cmd.node = node->Node(); SendToPort(fControlPort, TIMESOURCE_ADD_SLAVE_NODE, &cmd, sizeof(cmd)); } else { - if (this == dynamic_cast(node)) - debugger("fuck you!"); DirectAddMe(node->Node()); } return B_OK; From phoudoin at mail.berlios.de Thu Feb 7 00:10:14 2008 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Thu, 7 Feb 2008 00:10:14 +0100 Subject: [Haiku-commits] r23901 - in haiku/trunk: headers/os/drivers src/add-ons/kernel/bus_managers/acpi src/add-ons/kernel/bus_managers/firewire src/add-ons/kernel/generic/dpc Message-ID: <200802062310.m16NAEmu004397@sheep.berlios.de> Author: phoudoin Date: 2008-02-07 00:10:13 +0100 (Thu, 07 Feb 2008) New Revision: 23901 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23901&view=rev Modified: haiku/trunk/headers/os/drivers/dpc.h haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci.c haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c Log: Made DPC module binary compatible with BeOS one. Modified: haiku/trunk/headers/os/drivers/dpc.h =================================================================== --- haiku/trunk/headers/os/drivers/dpc.h 2008-02-06 22:08:25 UTC (rev 23900) +++ haiku/trunk/headers/os/drivers/dpc.h 2008-02-06 23:10:13 UTC (rev 23901) @@ -1,26 +1,28 @@ /* DPC module API - * Copyright 2007, Haiku Inc. All Rights Reserved. + * Copyright 2007-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License */ #ifndef _DPC_MODULE_H_ #define _DPC_MODULE_H_ +#include #include #ifdef __cplusplus extern "C" { #endif -#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" +#define B_DPC_MODULE_NAME "generic/dpc/v1" typedef void (*dpc_func) (void *arg); typedef struct { - module_info info; - void * (*new_dpc_queue)(const char *name, long priority, int queue_size); + module_info info; + + status_t (*new_dpc_queue)(void **queue, const char *name, int32 priority); status_t (*delete_dpc_queue)(void *queue); - status_t (*queue_dpc)(void *queue, dpc_func dpc_name, void *arg); + status_t (*queue_dpc)(void *queue, dpc_func func, void *arg); } dpc_module_info; @@ -28,4 +30,4 @@ } #endif -#endif +#endif // _DPC_MODULE_H_ Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2008-02-06 22:08:25 UTC (rev 23900) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2008-02-06 23:10:13 UTC (rev 23901) @@ -110,7 +110,10 @@ } #endif - gDPChandle = gDPC->new_dpc_queue("acpi_task", B_NORMAL_PRIORITY, 10); + if (gDPC->new_dpc_queue(&gDPChandle, "acpi_task", B_NORMAL_PRIORITY) != B_OK) { + ERROR("AcpiInitializeSubsystem failed (new_dpc_queue() failed!)\n"); + goto err; + } #ifdef ACPI_DEBUG_OUTPUT AcpiDbgLevel = ACPI_DEBUG_ALL | ACPI_LV_VERBOSE; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci.c 2008-02-06 22:08:25 UTC (rev 23900) +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci.c 2008-02-06 23:10:13 UTC (rev 23901) @@ -764,7 +764,7 @@ TASK_INIT(&sc->fwohci_task_busreset, 2, fwohci_task_busreset, sc); TASK_INIT(&sc->fwohci_task_sid, 1, fwohci_task_sid, sc); TASK_INIT(&sc->fwohci_task_dma, 0, fwohci_task_dma, sc);*/ - sc->fc.taskqueue = gDpc->new_dpc_queue("fw_taskq", FW_TASKQ_PRI, FW_TASKQ_SIZE); + gDpc->new_dpc_queue(&sc->fc.taskqueue, "fw_taskq", FW_TASKQ_PRI); fw_init(&sc->fc); fwohci_reset(sc); Modified: haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2008-02-06 22:08:25 UTC (rev 23900) +++ haiku/trunk/src/add-ons/kernel/generic/dpc/dpc.c 2008-02-06 23:10:13 UTC (rev 23901) @@ -35,6 +35,7 @@ // size * slots follow } dpc_queue; +#define DPC_QUEUE_SIZE 64 static int32 dpc_thread(void *arg) @@ -74,18 +75,21 @@ // ---- Public API -static void * -new_dpc_queue(const char *name, long priority, int queue_size) +static status_t +new_dpc_queue(void **handle, const char *name, int32 priority) { char str[64]; dpc_queue *queue; - queue = malloc(sizeof(dpc_queue) + queue_size * sizeof(dpc_slot)); + if (!handle) + return B_BAD_VALUE; + + queue = malloc(sizeof(dpc_queue) + DPC_QUEUE_SIZE * sizeof(dpc_slot)); if (!queue) - return NULL; + return B_NO_MEMORY; queue->head = queue->tail = 0; - queue->size = queue_size; + queue->size = DPC_QUEUE_SIZE; queue->count = 0; queue->lock = 0; // Init the spinlock @@ -100,8 +104,9 @@ queue->wakeup_sem = create_sem(0, str); if (queue->wakeup_sem < B_OK) { + status_t status = queue->wakeup_sem; free(queue); - return NULL; + return status; } set_sem_owner(queue->wakeup_sem, B_SYSTEM_TEAM); @@ -109,13 +114,16 @@ // the queued/deferred procedure calls queue->thread = spawn_kernel_thread(dpc_thread, name, priority, queue); if (queue->thread < 0) { + status_t status = queue->thread; delete_sem(queue->wakeup_sem); free(queue); - return NULL; + return status; } resume_thread(queue->thread); - return queue; + *handle = queue; + + return B_OK; } From phoudoin at mail.berlios.de Thu Feb 7 00:14:37 2008 From: phoudoin at mail.berlios.de (phoudoin at BerliOS) Date: Thu, 7 Feb 2008 00:14:37 +0100 Subject: [Haiku-commits] r23902 - haiku/trunk/build/jam Message-ID: <200802062314.m16NEbip004888@sheep.berlios.de> Author: phoudoin Date: 2008-02-07 00:14:37 +0100 (Thu, 07 Feb 2008) New Revision: 23902 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23902&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Added marvell_yukon driver, tested on real hardware (P5W-DH motherboard have two of those gigabit ethernet controllers), seems to work fine. * Add libglut.so alias to the development libs symlinks. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-06 23:10:13 UTC (rev 23901) +++ haiku/trunk/build/jam/HaikuImage 2008-02-06 23:14:37 UTC (rev 23902) @@ -122,6 +122,7 @@ BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)via_rhine wb840 net_stack $(X86_ONLY)ipro100 $(X86_ONLY)nforce #vlance + $(X86_ONLY)marvell_yukon $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; @@ -487,7 +488,8 @@ # library symlinks local lib ; - for lib in $(BEOS_SYSTEM_LIBS) $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { + for lib in $(BEOS_SYSTEM_LIBS) + $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) libglut.so { AddSymlinkToHaikuImage develop lib x86 : /system/lib/$(lib:BS) ; } } From bonefish at mail.berlios.de Thu Feb 7 01:26:03 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 01:26:03 +0100 Subject: [Haiku-commits] r23903 - in haiku/trunk: build/jam src/bin Message-ID: <200802070026.m170Q3RD004743@sheep.berlios.de> Author: bonefish Date: 2008-02-07 01:26:02 +0100 (Thu, 07 Feb 2008) New Revision: 23903 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23903&view=rev Added: haiku/trunk/src/bin/c++ haiku/trunk/src/bin/cc Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/bin/Jamfile Log: Added cc and c++ wrapper scripts. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-06 23:14:37 UTC (rev 23902) +++ haiku/trunk/build/jam/HaikuImage 2008-02-07 00:26:02 UTC (rev 23903) @@ -492,6 +492,9 @@ $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) libglut.so { AddSymlinkToHaikuImage develop lib x86 : /system/lib/$(lib:BS) ; } + + # cc and c++ wrapper scripts + AddFilesToHaikuImage beos bin : cc c++ ; } # Vision Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2008-02-06 23:14:37 UTC (rev 23902) +++ haiku/trunk/src/bin/Jamfile 2008-02-07 00:26:02 UTC (rev 23903) @@ -152,6 +152,9 @@ filepanel.cpp : be tracker : $(haiku-utils_rsrc) ; +# cc and c++ wrapper scripts +SEARCH on cc c++ = $(SUBDIR) ; + SubInclude HAIKU_TOP src bin addattr ; SubInclude HAIKU_TOP src bin bash ; SubInclude HAIKU_TOP src bin bc ; Added: haiku/trunk/src/bin/c++ =================================================================== --- haiku/trunk/src/bin/c++ 2008-02-06 23:14:37 UTC (rev 23902) +++ haiku/trunk/src/bin/c++ 2008-02-07 00:26:02 UTC (rev 23903) @@ -0,0 +1,2 @@ +#!/bin/sh +exec $BE_CPLUS_COMPILER $BE_DEFAULT_C_FLAGS $BE_DEFAULT_CPLUS_FLAGS $* Property changes on: haiku/trunk/src/bin/c++ ___________________________________________________________________ Name: svn:executable + * Added: haiku/trunk/src/bin/cc =================================================================== --- haiku/trunk/src/bin/cc 2008-02-06 23:14:37 UTC (rev 23902) +++ haiku/trunk/src/bin/cc 2008-02-07 00:26:02 UTC (rev 23903) @@ -0,0 +1,2 @@ +#!/bin/sh +exec $BE_C_COMPILER $BE_DEFAULT_C_FLAGS $* Property changes on: haiku/trunk/src/bin/cc ___________________________________________________________________ Name: svn:executable + * From bonefish at mail.berlios.de Thu Feb 7 03:22:48 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 03:22:48 +0100 Subject: [Haiku-commits] r23904 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . random Message-ID: <200802070222.m172Mm0F013995@sheep.berlios.de> Author: bonefish Date: 2008-02-07 03:22:48 +0100 (Thu, 07 Feb 2008) New Revision: 23904 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23904&view=rev Added: haiku/trunk/src/tests/add-ons/kernel/drivers/random/ haiku/trunk/src/tests/add-ons/kernel/drivers/random/Jamfile haiku/trunk/src/tests/add-ons/kernel/drivers/random/random_test.cpp Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile Log: Added small test program that opens and reads a few bytes from /dev/urandom. It verifies that Haiku's dev/urandom is performance-wise totally unusable -- it takes several seconds. Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile 2008-02-07 00:26:02 UTC (rev 23903) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile 2008-02-07 02:22:48 UTC (rev 23904) @@ -1,3 +1,4 @@ SubDir HAIKU_TOP src tests add-ons kernel drivers ; +SubInclude HAIKU_TOP src tests add-ons kernel drivers random ; SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ; Added: haiku/trunk/src/tests/add-ons/kernel/drivers/random/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/random/Jamfile 2008-02-07 00:26:02 UTC (rev 23903) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/random/Jamfile 2008-02-07 02:22:48 UTC (rev 23904) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src tests add-ons kernel drivers random ; + +SimpleTest random_test : random_test.cpp ; Added: haiku/trunk/src/tests/add-ons/kernel/drivers/random/random_test.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/random/random_test.cpp 2008-02-07 00:26:02 UTC (rev 23903) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/random/random_test.cpp 2008-02-07 02:22:48 UTC (rev 23904) @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include + + +static const char* kRandomDevice = "/dev/urandom"; + + +int +main() +{ + int fd = open(kRandomDevice, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "Error: Failed to open \"%s\": %s", kRandomDevice, + strerror(errno)); + exit(1); + } + + uint8_t buffer[16]; + ssize_t bytesRead = read(fd, buffer, sizeof(buffer)); + if (bytesRead < 0) { + fprintf(stderr, "Error: Failed to read from random device: %s", + strerror(errno)); + exit(1); + } + + printf("Read %d bytes from random device: ", (int)bytesRead); + for (int i = 0; i < bytesRead; i++) + printf("%02x", buffer[i]); + printf("\n"); + + return 0; +} + From korli at users.berlios.de Thu Feb 7 10:07:09 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Feb 2008 10:07:09 +0100 Subject: [Haiku-commits] r23904 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . random In-Reply-To: <200802070222.m172Mm0F013995@sheep.berlios.de> References: <200802070222.m172Mm0F013995@sheep.berlios.de> Message-ID: 2008/2/7, bonefish at BerliOS : > Added small test program that opens and reads a few bytes from > /dev/urandom. It verifies that Haiku's dev/urandom is performance-wise > totally unusable -- it takes several seconds. > You mean on real hardware ? Bye, J?r?me From marcusoverhagen at arcor.de Thu Feb 7 10:29:01 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 7 Feb 2008 10:29:01 +0100 (CET) Subject: [Haiku-commits] r23903 - in haiku/trunk: build/jam src/bin In-Reply-To: <200802070026.m170Q3RD004743@sheep.berlios.de> References: <200802070026.m170Q3RD004743@sheep.berlios.de> Message-ID: <14870817.1202376541814.JavaMail.ngmail@webmail11> An additional link: http://www.ntfs.com/partition-table.htm regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From stefano.ceccherini at gmail.com Thu Feb 7 10:43:07 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 7 Feb 2008 10:43:07 +0100 Subject: [Haiku-commits] r23904 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . random In-Reply-To: References: <200802070222.m172Mm0F013995@sheep.berlios.de> Message-ID: <894b9700802070143l1c6f5ac1k3c30867fc8bef722@mail.gmail.com> 2008/2/7, J?r?me Duval : > 2008/2/7, bonefish at BerliOS : > > Added small test program that opens and reads a few bytes from > > /dev/urandom. It verifies that Haiku's dev/urandom is performance-wise > > totally unusable -- it takes several seconds. > > > > You mean on real hardware ? > It does that on vmware at least. From axeld at pinc-software.de Thu Feb 7 10:45:46 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 07 Feb 2008 10:45:46 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23904_-_in_haiku/trunk/src/tests?= =?iso-8859-15?q?/add-ons/kernel/drivers=3A_=2E_random?= In-Reply-To: <200802070222.m172Mm0F013995@sheep.berlios.de> Message-ID: <1836826615-BeMail@zon> bonefish at BerliOS wrote: > Log: > Added small test program that opens and reads a few bytes from > /dev/urandom. It verifies that Haiku's dev/urandom is performance- > wise > totally unusable -- it takes several seconds. See http://dev.haiku-os.org/ticket/1366 Bye, Axel. From ingo_weinhold at gmx.de Thu Feb 7 10:58:12 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 07 Feb 2008 10:58:12 +0100 Subject: [Haiku-commits] r23904 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . random In-Reply-To: References: <200802070222.m172Mm0F013995@sheep.berlios.de> Message-ID: <20080207105812.401.1@knochen-vm.1202377692.fake> On 2008-02-07 at 10:07:09 [+0100], J?r?me Duval wrote: > 2008/2/7, bonefish at BerliOS : > > Added small test program that opens and reads a few bytes from > > /dev/urandom. It verifies that Haiku's dev/urandom is performance-wise > > totally unusable -- it takes several seconds. > > > > You mean on real hardware ? I measured move than 4s in VMware, but it should be more or less the same value on real hardware, since it's basically a loop that does 8 * 8 * 257 * snooze(100). It's definitely the reason why building Perl under is extremely slow -- miniperl seems to set it's internal seed using /dev/random when started. CU, Ingo From zharik at gmx.li Thu Feb 7 11:13:44 2008 From: zharik at gmx.li (Siarzhuk Zharski) Date: Thu, 07 Feb 2008 11:13:44 +0100 Subject: [Haiku-commits] r23904 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . random In-Reply-To: <894b9700802070143l1c6f5ac1k3c30867fc8bef722@mail.gmail.com> References: <200802070222.m172Mm0F013995@sheep.berlios.de> <894b9700802070143l1c6f5ac1k3c30867fc8bef722@mail.gmail.com> Message-ID: <47AAD9D8.70103@gmx.li> Hi, 07.02.2008 10:43 you wrote: > 2008/2/7, J?r?me Duval : > >> 2008/2/7, bonefish at BerliOS : >> >>> Added small test program that opens and reads a few bytes from >>> /dev/urandom. It verifies that Haiku's dev/urandom is performance-wise >>> totally unusable -- it takes several seconds. >>> >> You mean on real hardware ? > It does that on vmware at least. The same symptoms are observed under Virtual PC. Both under Haiku and BeOS. By the way, to force ssh to work in such environment I have to hack urandom driver by removing all snooze/thread_yield calls in reseed procedure. :-) Kind Regards, S.Zharski From jackburton at mail.berlios.de Thu Feb 7 11:50:40 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 11:50:40 +0100 Subject: [Haiku-commits] r23905 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200802071050.m17Aoee3000787@sheep.berlios.de> Author: jackburton Date: 2008-02-07 11:50:39 +0100 (Thu, 07 Feb 2008) New Revision: 23905 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23905&view=rev Modified: haiku/trunk/headers/os/interface/Input.h haiku/trunk/src/kits/interface/Input.cpp Log: Rewrote Input.h, adjusted Input.cpp accordingly, added nothrow on allocations. Modified: haiku/trunk/headers/os/interface/Input.h =================================================================== --- haiku/trunk/headers/os/interface/Input.h 2008-02-07 02:22:48 UTC (rev 23904) +++ haiku/trunk/headers/os/interface/Input.h 2008-02-07 10:50:39 UTC (rev 23905) @@ -1,12 +1,8 @@ -/****************************************************************************** -/ -/ File: Input.h -/ -/ Description: Functions and class to manage input devices. -/ -/ Copyright 1998, Be Incorporated, All Rights Reserved. -/ -******************************************************************************/ +/* + * Copyright (c) 2008, Haiku, Inc. + * Distributed under the terms of the MIT license. + * + */ #ifndef _INPUT_H #define _INPUT_H @@ -15,13 +11,11 @@ #include #include -class BList; - enum input_method_op { B_INPUT_METHOD_STARTED = 0, B_INPUT_METHOD_STOPPED = 1, - B_INPUT_METHOD_CHANGED = 2, + B_INPUT_METHOD_CHANGED = 2, B_INPUT_METHOD_LOCATION_REQUEST = 3 }; @@ -32,14 +26,9 @@ B_UNDEFINED_DEVICE = 2 }; -/* - what == B_INPUT_DEVICES_CHANGED - FindString("name", name_of_device); - FindInt32("opcode", input_device_notification); -*/ enum input_device_notification { - B_INPUT_DEVICE_ADDED = 0x0001, + B_INPUT_DEVICE_ADDED = 0x0001, B_INPUT_DEVICE_STARTED = 0x0002, B_INPUT_DEVICE_STOPPED = 0x0004, B_INPUT_DEVICE_REMOVED = 0x0008 @@ -47,10 +36,10 @@ class BInputDevice; +class BList; - -BInputDevice* find_input_device(const char *name); -status_t get_input_devices(BList *list); +BInputDevice* find_input_device(const char* name); +status_t get_input_devices(BList* list); status_t watch_input_devices(BMessenger target, bool start); @@ -64,27 +53,25 @@ status_t Start(); status_t Stop(); - status_t Control(uint32 code, - BMessage *message); - + status_t Control(uint32 code, BMessage* message); + static status_t Start(input_device_type type); static status_t Stop(input_device_type type); - static status_t Control(input_device_type type, - uint32 code, - BMessage *message); - + static status_t Control(input_device_type type, + uint32 code, + BMessage* message); + private: - friend BInputDevice* find_input_device(const char *name); - friend status_t get_input_devices(BList *list); + friend BInputDevice* find_input_device(const char* name); + friend status_t get_input_devices(BList* list); BInputDevice(); - void set_name_and_type(const char *name, + void _SetNameAndType(const char* name, input_device_type type); - + char* fName; input_device_type fType; uint32 _reserved[4]; }; - #endif Modified: haiku/trunk/src/kits/interface/Input.cpp =================================================================== --- haiku/trunk/src/kits/interface/Input.cpp 2008-02-07 02:22:48 UTC (rev 23904) +++ haiku/trunk/src/kits/interface/Input.cpp 2008-02-07 10:50:39 UTC (rev 23905) @@ -1,30 +1,14 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: Input.cpp -// Author: Marc Flerackers (mflerackers at androme.be) -// Description: Functions and class to manage input devices. -//------------------------------------------------------------------------------ +/* + * Copyright (c) 2001-2008, Haiku, Inc. + * Distributed under the terms of the MIT license. + * + * Author: Marc Flerackers (mflerackers at androme.be) + * Description: Functions and class to manage input devices. + */ + #include #include +#include #include #include @@ -50,15 +34,17 @@ if (err != B_OK) return NULL; - BInputDevice *dev = new BInputDevice; - + BInputDevice *dev = new (std::nothrow) BInputDevice; + if (dev == NULL) + return NULL; + const char *device; int32 type; reply.FindString("device", &device); reply.FindInt32("type", &type); - dev->set_name_and_type(device, (input_device_type)type); + dev->_SetNameAndType(device, (input_device_type)type); return dev; } @@ -84,11 +70,11 @@ while (reply.FindString("device", i, &name) == B_OK) { reply.FindInt32("type", i++, &type); - BInputDevice *dev = new BInputDevice; - - dev->set_name_and_type(name, (input_device_type)type); - - list->AddItem(dev); + BInputDevice *dev = new (std::nothrow) BInputDevice; + if (dev != NULL) { + dev->_SetNameAndType(name, (input_device_type)type); + list->AddItem(dev); + } } return err; @@ -244,17 +230,18 @@ BInputDevice::BInputDevice() + : + fName(NULL), + fType(B_UNDEFINED_DEVICE) { - fName = NULL; - fType = B_UNDEFINED_DEVICE; } void -BInputDevice::set_name_and_type(const char *name, input_device_type type) +BInputDevice::_SetNameAndType(const char *name, input_device_type type) { if (fName) { - free (fName); + free(fName); fName = NULL; } @@ -268,9 +255,12 @@ status_t _control_input_server_(BMessage *command, BMessage *reply) { - if (!sInputServer) - sInputServer = new BMessenger; - + if (!sInputServer) { + sInputServer = new (std::nothrow) BMessenger; + if (!sInputServer) + return B_NO_MEMORY; + } + if (!sInputServer->IsValid()) *sInputServer = BMessenger("application/x-vnd.Be-input_server", -1, NULL); From bonefish at mail.berlios.de Thu Feb 7 12:40:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 12:40:42 +0100 Subject: [Haiku-commits] r23906 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm Message-ID: <200802071140.m17BeghX026362@sheep.berlios.de> Author: bonefish Date: 2008-02-07 12:40:31 +0100 (Thu, 07 Feb 2008) New Revision: 23906 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23906&view=rev Modified: haiku/trunk/headers/private/kernel/thread.h haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: Added a boolean "force" parameter to thread_yield(). When true, the function has the old behavior. When false, it just calls the scheduler without any priority adjustment or other stuff. Modified: haiku/trunk/headers/private/kernel/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/thread.h 2008-02-07 10:50:39 UTC (rev 23905) +++ haiku/trunk/headers/private/kernel/thread.h 2008-02-07 11:40:31 UTC (rev 23906) @@ -34,7 +34,7 @@ status_t thread_init(struct kernel_args *args); status_t thread_preboot_init_percpu(struct kernel_args *args, int32 cpuNum); -void thread_yield(void); +void thread_yield(bool force); void thread_exit(void); int32 thread_max_threads(void); Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-02-07 10:50:39 UTC (rev 23905) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-02-07 11:40:31 UTC (rev 23906) @@ -1622,29 +1622,45 @@ } +/*! Yield the CPU to other threads. + If \a force is \c true, the thread will almost guaranteedly be unscheduled. + If \c false, it will continue to run, if there's no other thread in ready + state, and if it has a higher priority than the other ready threads, it + still has a good chance to continue. +*/ void -thread_yield(void) +thread_yield(bool force) { - // snooze for roughly 3 thread quantums - snooze_etc(9000, B_SYSTEM_TIMEBASE, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT); + if (force) { + // snooze for roughly 3 thread quantums + snooze_etc(9000, B_SYSTEM_TIMEBASE, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT); #if 0 - cpu_status state; + cpu_status state; - struct thread *thread = thread_get_current_thread(); - if (thread == NULL) - return; + struct thread *thread = thread_get_current_thread(); + if (thread == NULL) + return; - state = disable_interrupts(); - GRAB_THREAD_LOCK(); + state = disable_interrupts(); + GRAB_THREAD_LOCK(); - // mark the thread as yielded, so it will not be scheduled next - //thread->was_yielded = true; - thread->next_priority = B_LOWEST_ACTIVE_PRIORITY; - scheduler_reschedule(); + // mark the thread as yielded, so it will not be scheduled next + //thread->was_yielded = true; + thread->next_priority = B_LOWEST_ACTIVE_PRIORITY; + scheduler_reschedule(); - RELEASE_THREAD_LOCK(); - restore_interrupts(state); + RELEASE_THREAD_LOCK(); + restore_interrupts(state); #endif + } else { + struct thread *thread = thread_get_current_thread(); + if (thread == NULL) + return; + + // Don't force the thread off the CPU, just reschedule. + InterruptsSpinLocker _(thread_spinlock); + scheduler_reschedule(); + } } @@ -2463,7 +2479,7 @@ void _user_thread_yield(void) { - thread_yield(); + thread_yield(true); } Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-02-07 10:50:39 UTC (rev 23905) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-02-07 11:40:31 UTC (rev 23906) @@ -718,7 +718,7 @@ memcpy(fItems, originalItems, fCount * sizeof(lock_item)); if (yield) - thread_yield(); + thread_yield(true); } } @@ -3941,7 +3941,7 @@ // with his only consumer (cacheRef); since its pages are moved // upwards, too, we try this cache again mutex_unlock(&cache->lock); - thread_yield(); + thread_yield(true); mutex_lock(&cache->lock); if (cache->busy) { // The cache became busy, which means, it is about to be Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-02-07 10:50:39 UTC (rev 23905) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-02-07 11:40:31 UTC (rev 23906) @@ -959,7 +959,7 @@ if (cache->store->ops->acquire_unreferenced_ref(cache->store) != B_OK) { cacheLocker.Unlock(); - thread_yield(); + thread_yield(true); continue; } } From bonefish at mail.berlios.de Thu Feb 7 12:42:19 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 12:42:19 +0100 Subject: [Haiku-commits] r23907 - haiku/trunk/src/add-ons/kernel/drivers/random Message-ID: <200802071142.m17BgJYR029136@sheep.berlios.de> Author: bonefish Date: 2008-02-07 12:42:18 +0100 (Thu, 07 Feb 2008) New Revision: 23907 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23907&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/random/driver.c Log: Use thread_yield(false) instead of snooze(100) for reseeding. This makes the driver actually usuable. Modified: haiku/trunk/src/add-ons/kernel/drivers/random/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/random/driver.c 2008-02-07 11:40:31 UTC (rev 23906) +++ haiku/trunk/src/add-ons/kernel/drivers/random/driver.c 2008-02-07 11:42:18 UTC (rev 23907) @@ -191,9 +191,7 @@ for (j = initTimes; j; j--) { for (i = NK * initTimes; i; i--) { - //thread_yield(); - snooze(100); - // TODO: Our thread_yield() currently waits too long for emulators... + thread_yield(false); y.Q[0] += system_time(); attach(&x, &y, 0x52437EFFU, 0x026A4CEBU, 0xD9E66AC9U, 0x56E5A975U); From jackburton at mail.berlios.de Thu Feb 7 14:29:42 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 14:29:42 +0100 Subject: [Haiku-commits] r23908 - in haiku/trunk/src/tests/apps: . terminal_replicant Message-ID: <200802071329.m17DTgxO003361@sheep.berlios.de> Author: jackburton Date: 2008-02-07 14:29:41 +0100 (Thu, 07 Feb 2008) New Revision: 23908 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23908&view=rev Added: haiku/trunk/src/tests/apps/terminal_replicant/ haiku/trunk/src/tests/apps/terminal_replicant/Jamfile haiku/trunk/src/tests/apps/terminal_replicant/main.cpp Modified: haiku/trunk/src/tests/apps/Jamfile Log: Added a pretty useless test app to show that embedding a TermView in another apps works correctly (minus the blinking cursor, we'll see why it doesn't) Modified: haiku/trunk/src/tests/apps/Jamfile =================================================================== --- haiku/trunk/src/tests/apps/Jamfile 2008-02-07 11:42:18 UTC (rev 23907) +++ haiku/trunk/src/tests/apps/Jamfile 2008-02-07 13:29:41 UTC (rev 23908) @@ -4,4 +4,5 @@ SubInclude HAIKU_TOP src tests apps installer ; SubInclude HAIKU_TOP src tests apps miniterminal ; SubInclude HAIKU_TOP src tests apps partitioner ; +SubInclude HAIKU_TOP src tests apps terminal_replicant ; Added: haiku/trunk/src/tests/apps/terminal_replicant/Jamfile =================================================================== --- haiku/trunk/src/tests/apps/terminal_replicant/Jamfile 2008-02-07 11:42:18 UTC (rev 23907) +++ haiku/trunk/src/tests/apps/terminal_replicant/Jamfile 2008-02-07 13:29:41 UTC (rev 23908) @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src tests apps terminal_replicant ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +SubDirHdrs [ FDirName $(HAIKU_TOP) src apps terminal ] ; + +Application RepliTerminal : + main.cpp + : be + ; + +SEARCH on [ FGristFiles TermView.h ] = [ FDirName $(HAIKU_TOP) src apps terminal ] ; Added: haiku/trunk/src/tests/apps/terminal_replicant/main.cpp =================================================================== --- haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 11:42:18 UTC (rev 23907) +++ haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 13:29:41 UTC (rev 23908) @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "TermConst.h" +#include "TermView.h" + +class App : public BApplication { +public: + App(); +}; + + +class Window : public BWindow { +public: + Window(); + void AttachTermView(); +private: + BShelf *fShelf; +}; + + +int main() +{ + App app; + app.Run(); + return 0; +} + + +// App +App::App() + :BApplication("application/x-vnd-terminal-replicant") +{ + Window *window = new Window(); + window->Show(); +} + + +// Window +Window::Window() + :BWindow(BRect(20, 20, 300, 300), "RepliTerminal", + B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_QUIT_ON_WINDOW_CLOSE) +{ + AttachTermView(); +} + + +void +Window::AttachTermView() +{ + // BMessage containing the class name and the app_signature + // for Terminal and TermView + BMessage message; + message.AddString("class", "TermView"); + message.AddString("add_on", TERM_SIGNATURE); + + BView *termView = dynamic_cast(instantiate_object(&message)); + + if (termView != NULL) { + termView->SetResizingMode(B_FOLLOW_ALL); + AddChild(termView); + + termView->ResizeToPreferred(); + } +} From jackburton at mail.berlios.de Thu Feb 7 14:30:40 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 14:30:40 +0100 Subject: [Haiku-commits] r23909 - haiku/trunk/src/apps/terminal Message-ID: <200802071330.m17DUeuJ003613@sheep.berlios.de> Author: jackburton Date: 2008-02-07 14:30:39 +0100 (Thu, 07 Feb 2008) New Revision: 23909 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23909&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Set the low and view color on construction, and set the B_WILL_DRAW flag too, since we can't do anything without it. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 13:29:41 UTC (rev 23908) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 13:30:39 UTC (rev 23909) @@ -265,7 +265,13 @@ status = _AttachShell(fShell); if (status < B_OK) return status; - + + // We need this + SetFlags(Flags() | B_WILL_DRAW); + + SetLowColor(fTextBackColor); + SetViewColor(fTextBackColor); + return B_OK; } From jackburton at mail.berlios.de Thu Feb 7 15:12:50 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 15:12:50 +0100 Subject: [Haiku-commits] r23910 - haiku/trunk/src/kits/interface Message-ID: <200802071412.m17ECo2h008643@sheep.berlios.de> Author: jackburton Date: 2008-02-07 15:12:49 +0100 (Thu, 07 Feb 2008) New Revision: 23910 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23910&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp Log: print also the view name in case it mixes up flags and resizing mode. Helps identifying it. Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2008-02-07 13:30:39 UTC (rev 23909) +++ haiku/trunk/src/kits/interface/View.cpp 2008-02-07 14:12:49 UTC (rev 23910) @@ -3412,7 +3412,6 @@ return false; if (child->fParent != NULL) { -printf("BView::_AddChild(): child %p already has parent %p\n", child , child->fParent); debugger("AddChild failed - the view already has a parent."); return false; } @@ -4196,7 +4195,7 @@ // initialize members if ((resizingMode & ~_RESIZE_MASK_) || (flags & _RESIZE_MASK_)) - printf("BView::InitData(): resizing mode or flags swapped\n"); + printf("%s BView::InitData(): resizing mode or flags swapped\n", name); // There are applications that swap the resize mask and the flags in the // BView constructor. This does not cause problems under BeOS as it just From jackburton at mail.berlios.de Thu Feb 7 15:14:03 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 15:14:03 +0100 Subject: [Haiku-commits] r23911 - in haiku/trunk/src: apps/terminal tests/apps/terminal_replicant Message-ID: <200802071414.m17EE3mg008832@sheep.berlios.de> Author: jackburton Date: 2008-02-07 15:14:02 +0100 (Thu, 07 Feb 2008) New Revision: 23911 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23911&view=rev Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/tests/apps/terminal_replicant/main.cpp Log: AppearPrefView was mixing up flags and resizing mode. Fixed. Also set the flag B_PULSE_NEEDED (for the blinking cursor) in TermView. Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-02-07 14:12:49 UTC (rev 23910) +++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-02-07 14:14:02 UTC (rev 23911) @@ -43,20 +43,20 @@ BMenu *menu = _MakeFontMenu(MSG_HALF_FONT_CHANGED, PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY)); - fFont = new BMenuField(r, "font", "Font:", menu, B_WILL_DRAW); + fFont = new BMenuField(r, "font", "Font:", menu); fFont->SetDivider(fontDividerSize); AddChild(fFont); r.OffsetBy(r.Width() + 10, 0); menu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, PrefHandler::Default()->getInt32(PREF_HALF_FONT_SIZE)); - fFontSize = new BMenuField(r, "size", "Size:", menu, B_WILL_DRAW); + fFontSize = new BMenuField(r, "size", "Size:", menu); fFontSize->SetDivider(sizeDividerSize); AddChild(fFontSize); r.OffsetBy(-r.Width() - 10,r.Height() + 25); fColorField = new BMenuField(r, "color", "Change:", - MakeMenu(MSG_COLOR_FIELD_CHANGED, color_tbl, color_tbl[0]), B_WILL_DRAW); + MakeMenu(MSG_COLOR_FIELD_CHANGED, color_tbl, color_tbl[0])); fColorField->SetDivider(StringWidth(fColorField->Label()) + 8.0); AddChild(fColorField); Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 14:12:49 UTC (rev 23910) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 14:14:02 UTC (rev 23911) @@ -267,7 +267,7 @@ return status; // We need this - SetFlags(Flags() | B_WILL_DRAW); + SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); SetLowColor(fTextBackColor); SetViewColor(fTextBackColor); Modified: haiku/trunk/src/tests/apps/terminal_replicant/main.cpp =================================================================== --- haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 14:12:49 UTC (rev 23910) +++ haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 14:14:02 UTC (rev 23911) @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -45,8 +46,8 @@ // Window Window::Window() - :BWindow(BRect(20, 20, 300, 300), "RepliTerminal", - B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_QUIT_ON_WINDOW_CLOSE) + :BWindow(BRect(100, 100, 400, 360), "RepliTerminal", + B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS|B_QUIT_ON_WINDOW_CLOSE) { AttachTermView(); } From michael.pfeiffer at utanet.at Thu Feb 7 15:09:08 2008 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Thu, 7 Feb 2008 15:09:08 +0100 Subject: [Haiku-commits] r23908 - in haiku/trunk/src/tests/apps: . terminal_replicant In-Reply-To: <200802071329.m17DTgxO003361@sheep.berlios.de> References: <200802071329.m17DTgxO003361@sheep.berlios.de> Message-ID: <0CA4ABB0-9546-4D81-A57B-BBCD718BDB9B@utanet.at> Am 07.02.2008 um 14:29 schrieb jackburton at BerliOS: > Added a pretty useless test app to show that embedding a TermView in > another apps works correctly (minus the blinking cursor, we'll see why > it doesn't) Shouldn't the flags (B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED) also be set in the constructor TermView::TermView(BMessage *archive)? - Michael From stefano.ceccherini at gmail.com Thu Feb 7 15:30:59 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 7 Feb 2008 15:30:59 +0100 Subject: [Haiku-commits] r23908 - in haiku/trunk/src/tests/apps: . terminal_replicant In-Reply-To: <0CA4ABB0-9546-4D81-A57B-BBCD718BDB9B@utanet.at> References: <200802071329.m17DTgxO003361@sheep.berlios.de> <0CA4ABB0-9546-4D81-A57B-BBCD718BDB9B@utanet.at> Message-ID: <894b9700802070630l5fc539c3k80a31a9a12470239@mail.gmail.com> 2008/2/7, Michael Pfeiffer : > > Am 07.02.2008 um 14:29 schrieb jackburton at BerliOS: > > > Added a pretty useless test app to show that embedding a TermView in > > another apps works correctly (minus the blinking cursor, we'll see why > > it doesn't) > > Shouldn't the flags (B_WILL_DRAW | B_FRAME_EVENTS | > B_FULL_UPDATE_ON_RESIZE > | B_PULSE_NEEDED) also be set in the constructor > TermView::TermView(BMessage *archive)? > Yes, that was the cause, I noticed that too, I added them in ::_InitObject(), called from every constructor. From jackburton at mail.berlios.de Thu Feb 7 15:38:10 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 15:38:10 +0100 Subject: [Haiku-commits] r23912 - haiku/trunk/src/tests/apps/terminal_replicant Message-ID: <200802071438.m17EcALL011950@sheep.berlios.de> Author: jackburton Date: 2008-02-07 15:38:10 +0100 (Thu, 07 Feb 2008) New Revision: 23912 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23912&view=rev Modified: haiku/trunk/src/tests/apps/terminal_replicant/Jamfile haiku/trunk/src/tests/apps/terminal_replicant/main.cpp Log: We don't need TermView.h Modified: haiku/trunk/src/tests/apps/terminal_replicant/Jamfile =================================================================== --- haiku/trunk/src/tests/apps/terminal_replicant/Jamfile 2008-02-07 14:14:02 UTC (rev 23911) +++ haiku/trunk/src/tests/apps/terminal_replicant/Jamfile 2008-02-07 14:38:10 UTC (rev 23912) @@ -9,4 +9,4 @@ : be ; -SEARCH on [ FGristFiles TermView.h ] = [ FDirName $(HAIKU_TOP) src apps terminal ] ; + Modified: haiku/trunk/src/tests/apps/terminal_replicant/main.cpp =================================================================== --- haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 14:14:02 UTC (rev 23911) +++ haiku/trunk/src/tests/apps/terminal_replicant/main.cpp 2008-02-07 14:38:10 UTC (rev 23912) @@ -10,7 +10,7 @@ #include #include "TermConst.h" -#include "TermView.h" + // for the Terminal's signature class App : public BApplication { public: From jackburton at mail.berlios.de Thu Feb 7 15:52:17 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 15:52:17 +0100 Subject: [Haiku-commits] r23913 - haiku/trunk/src/apps/terminal Message-ID: <200802071452.m17EqHRM013236@sheep.berlios.de> Author: jackburton Date: 2008-02-07 15:52:16 +0100 (Thu, 07 Feb 2008) New Revision: 23913 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23913&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Call BScrollBar::SetSteps() with the correct values also on font change, and when a scrollbar is attached. Fixes bug #1759 Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 14:38:10 UTC (rev 23912) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 14:52:16 UTC (rev 23913) @@ -461,6 +461,10 @@ fTop = fTop * fFontHeight; fCursorHeight = fFontHeight; + + if (fScrollBar != NULL) { + fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + } } @@ -468,6 +472,9 @@ TermView::SetScrollBar(BScrollBar *scrollBar) { fScrollBar = scrollBar; + if (fScrollBar != NULL) { + fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + } } @@ -2295,9 +2302,7 @@ void TermView::NotifyQuit(int32 reason) { - // TODO: If we are a replicant, we can't just quit the BWindow, no?. - // Exactly, and the same is true for tabs! - Window()->PostMessage(B_QUIT_REQUESTED); + // implemented in subclasses } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2008-02-07 14:38:10 UTC (rev 23912) +++ haiku/trunk/src/apps/terminal/TermView.h 2008-02-07 14:52:16 UTC (rev 23913) @@ -155,7 +155,7 @@ inline void _Redraw(int, int, int, int); void _DoPrint(BRect updateRect); - void _ResizeScrBarRange (void); + void _ResizeScrBarRange(void); void _DoFileDrop(entry_ref &ref); void _WritePTY(const uchar *text, int num_byteses); From jackburton at mail.berlios.de Thu Feb 7 16:06:31 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 7 Feb 2008 16:06:31 +0100 Subject: [Haiku-commits] r23914 - haiku/trunk/src/apps/terminal Message-ID: <200802071506.m17F6V1t015633@sheep.berlios.de> Author: jackburton Date: 2008-02-07 16:06:30 +0100 (Thu, 07 Feb 2008) New Revision: 23914 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23914&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Also set the scrollbar steps when the terminal size changes. Moved SetFlags() from _InitObject() to unarchiving constructor as other constructors already set the flags. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 14:52:16 UTC (rev 23913) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-07 15:06:30 UTC (rev 23914) @@ -235,6 +235,9 @@ if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK) fTermRows = ROWS_DEFAULT; + // We need this + SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); + // TODO: Retrieve arguments, colors, history size, etc. from archive _InitObject(0, NULL); } @@ -266,8 +269,6 @@ if (status < B_OK) return status; - // We need this - SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); SetLowColor(fTextBackColor); SetViewColor(fTextBackColor); @@ -364,6 +365,9 @@ if (resize) ResizeTo(rect.Width(), rect.Height()); + if (fScrollBar != NULL) + fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + return rect; } @@ -424,7 +428,6 @@ void TermView::SetTermFont(const BFont *font) { - char buf[4]; int halfWidth = 0; fHalfFont = font; @@ -434,6 +437,7 @@ // calculate half font's max width // Not Bounding, check only A-Z(For case of fHalfFont is KanjiFont. ) for (int c = 0x20 ; c <= 0x7e; c++){ + char buf[4]; sprintf(buf, "%c", c); int tmpWidth = (int)fHalfFont.StringWidth(buf); if (tmpWidth > halfWidth) From axeld at mail.berlios.de Thu Feb 7 16:09:20 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Feb 2008 16:09:20 +0100 Subject: [Haiku-commits] r23915 - in haiku/trunk: headers/private/net src/add-ons/kernel/network/protocols/icmp src/add-ons/kernel/network/protocols/ipv4 src/add-ons/kernel/network/protocols/tcp src/add-ons/kernel/network/protocols/udp src/add-ons/kernel/network/stack Message-ID: <200802071509.m17F9K3n015790@sheep.berlios.de> Author: axeld Date: 2008-02-07 16:09:19 +0100 (Thu, 07 Feb 2008) New Revision: 23915 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23915&view=rev Modified: haiku/trunk/headers/private/net/net_protocol.h haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp haiku/trunk/src/add-ons/kernel/network/stack/link.cpp haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp Log: * Added flags field in net_protocol_module_info; there is currently a single defined flag: NET_PROTOCOL_ATOMIC_MESSAGES. * socket_send() now honours NET_PROTOCOL_ATOMIC_MESSAGES and returns either EMSGSIZE if the data to be send is larger than net_socket::send::buffer_size, or divides the data in appropriately sized chunks. * This fixes sending >=64K over a TCP socket at once (TCP would just have returned an error in that case). * TCP now overrides the default send buffer size (to 32768 for now). Modified: haiku/trunk/headers/private/net/net_protocol.h =================================================================== --- haiku/trunk/headers/private/net/net_protocol.h 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/headers/private/net/net_protocol.h 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef NET_PROTOCOL_H @@ -22,8 +22,12 @@ net_socket *socket; } net_protocol; +// net_protocol_module_info::flags field +#define NET_PROTOCOL_ATOMIC_MESSAGES 0x01 + struct net_protocol_module_info { module_info info; + uint32 flags; net_protocol *(*init_protocol)(net_socket *socket); status_t (*uninit_protocol)(net_protocol *self); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -338,6 +338,8 @@ 0, icmp_std_ops }, + NET_PROTOCOL_ATOMIC_MESSAGES, + icmp_init_protocol, icmp_uninit_protocol, icmp_open, Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -1698,6 +1698,8 @@ 0, ipv4_std_ops }, + NET_PROTOCOL_ATOMIC_MESSAGES, + ipv4_init_protocol, ipv4_uninit_protocol, ipv4_open, Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -564,7 +564,7 @@ if (buffer->size > 0) { if (buffer->size > fSendQueue.Size()) - return EMSGSIZE; + return ENOBUFS; bigtime_t timeout = absolute_timeout(socket->send.timeout); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -421,6 +421,9 @@ net_protocol * tcp_init_protocol(net_socket *socket) { + socket->send.buffer_size = 32768; + // override net_socket default + TCPEndpoint *protocol = new (std::nothrow) TCPEndpoint(socket); if (protocol == NULL) return NULL; @@ -775,6 +778,8 @@ 0, tcp_std_ops }, + 0, + tcp_init_protocol, tcp_uninit_protocol, tcp_open, Modified: haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -1230,6 +1230,8 @@ 0, udp_std_ops }, + NET_PROTOCOL_ATOMIC_MESSAGES, + udp_init_protocol, udp_uninit_protocol, udp_open, Modified: haiku/trunk/src/add-ons/kernel/network/stack/link.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/link.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/stack/link.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -477,6 +477,8 @@ 0, link_std_ops }, + NET_PROTOCOL_ATOMIC_MESSAGES, + link_init_protocol, link_uninit_protocol, link_open, Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-02-07 15:06:30 UTC (rev 23914) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-02-07 15:09:19 UTC (rev 23915) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -48,6 +48,23 @@ benaphore sSocketLock; +static size_t +compute_user_iovec_length(iovec *userVec, uint32 count) +{ + size_t length = 0; + + for (uint32 i = 0; i < count; i++) { + iovec vec; + if (user_memcpy(&vec, userVec + i, sizeof(iovec)) < B_OK) + return 0; + + length += vec.iov_len; + } + + return length; +} + + static status_t create_socket(int family, int type, int protocol, net_socket_private **_socket) { @@ -883,12 +900,16 @@ ssize_t -socket_send(net_socket *socket, msghdr *header, const void *data, - size_t length, int flags) +socket_send(net_socket *socket, msghdr *header, const void *data, size_t length, + int flags) { const sockaddr *address = NULL; socklen_t addressLength = 0; + size_t bytesLeft = length; + if (length > SSIZE_MAX) + return B_BAD_VALUE; + // the convention to this function is that have header been // present, { data, length } would have been iovec[0] and is // always considered like that @@ -899,6 +920,10 @@ if (header->msg_iovlen <= 1) header = NULL; + else { + bytesLeft += compute_user_iovec_length(header->msg_iov + 1, + header->msg_iovlen - 1); + } } if (addressLength == 0) @@ -920,6 +945,10 @@ return EDESTADDRREQ; } + if ((socket->first_info->flags & NET_PROTOCOL_ATOMIC_MESSAGES) != 0 + && bytesLeft > socket->send.buffer_size) + return EMSGSIZE; + if (socket->address.ss_len == 0) { // try to bind first status_t status = socket_bind(socket, NULL, 0); @@ -927,51 +956,79 @@ return status; } - // TODO: useful, maybe even computed header space! - net_buffer *buffer = gNetBufferModule.create(256); - if (buffer == NULL) - return ENOBUFS; + ssize_t bytesSent = 0; + size_t vecOffset = 0; + uint32 vecIndex = 0; - if (gNetBufferModule.append(buffer, data, length) < B_OK) { - gNetBufferModule.free(buffer); - return ENOBUFS; - } + while (bytesLeft > 0) { + // TODO: useful, maybe even computed header space! + net_buffer *buffer = gNetBufferModule.create(256); + if (buffer == NULL) + return ENOBUFS; - if (header) { - // copy additional data into buffer - for (int i = 1; i < header->msg_iovlen; i++) { - iovec vec; - if (user_memcpy(&vec, header->msg_iov + i, sizeof(iovec)) < B_OK) - return B_BAD_ADDRESS; - if (gNetBufferModule.append(buffer, vec.iov_base, - vec.iov_len) < B_OK) { + while (buffer->size < socket->send.buffer_size + && buffer->size < bytesLeft) { + if (vecIndex > 0 && vecOffset == 0) { + // retrieve next iovec buffer from header + iovec vec; + if (user_memcpy(&vec, header->msg_iov + vecIndex, sizeof(iovec)) + < B_OK) { + gNetBufferModule.free(buffer); + return B_BAD_ADDRESS; + } + + data = vec.iov_base; + length = vec.iov_len; + } + + size_t bytes = length; + if (buffer->size + bytes > socket->send.buffer_size) + bytes = socket->send.buffer_size - buffer->size; + + if (gNetBufferModule.append(buffer, data, bytes) < B_OK) { gNetBufferModule.free(buffer); return ENOBUFS; } - length += vec.iov_len; + if (bytes != length) { + // partial send + vecOffset = bytes; + length -= vecOffset; + data = (uint8 *)data + vecOffset; + } else if (header != NULL) { + // proceed with next buffer, if any + vecOffset = 0; + vecIndex++; + + if (vecIndex >= (uint32)header->msg_iovlen) + break; + } } - } - buffer->flags = flags; - memcpy(buffer->source, &socket->address, socket->address.ss_len); - memcpy(buffer->destination, address, addressLength); + size_t bufferSize = buffer->size; + buffer->flags = flags; + memcpy(buffer->source, &socket->address, socket->address.ss_len); + memcpy(buffer->destination, address, addressLength); - status_t status = socket->first_info->send_data(socket->first_protocol, - buffer); - if (status < B_OK) { - size_t size = buffer->size; - gNetBufferModule.free(buffer); + status_t status = socket->first_info->send_data(socket->first_protocol, + buffer); + if (status < B_OK) { + size_t sizeAfterSend = buffer->size; + gNetBufferModule.free(buffer); - if (size != length - && (status == B_INTERRUPTED || status == B_WOULD_BLOCK)) { - // this appears to be a partial write - return length - size; + if (sizeAfterSend != bufferSize + && (status == B_INTERRUPTED || status == B_WOULD_BLOCK)) { + // this appears to be a partial write + return bytesSent + (bufferSize - sizeAfterSend); + } + return status; } - return status; + + bytesLeft -= bufferSize; + bytesSent += bufferSize; } - return length; + return bytesSent; } From bonefish at mail.berlios.de Thu Feb 7 17:03:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 17:03:01 +0100 Subject: [Haiku-commits] r23916 - in haiku/trunk: headers/private/kernel src/tools/gensyscalls Message-ID: <200802071603.m17G31Iu023878@sheep.berlios.de> Author: bonefish Date: 2008-02-07 17:03:00 +0100 (Thu, 07 Feb 2008) New Revision: 23916 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23916&view=rev Modified: haiku/trunk/headers/private/kernel/ksyscalls.h haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp Log: Also include info about the syscall return type in the extended_syscall_info structure. Modified: haiku/trunk/headers/private/kernel/ksyscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/ksyscalls.h 2008-02-07 15:09:19 UTC (rev 23915) +++ haiku/trunk/headers/private/kernel/ksyscalls.h 2008-02-07 16:03:00 UTC (rev 23916) @@ -24,10 +24,17 @@ type_code type; } syscall_parameter_info; +typedef struct syscall_return_type_info { + int size; + int used_size; + type_code type; +} syscall_return_type_info; + typedef struct extended_syscall_info { - const char* name; - int parameter_count; - syscall_parameter_info parameters[MAX_SYSCALL_PARAMETERS]; + const char* name; + int parameter_count; + syscall_return_type_info return_type; + syscall_parameter_info parameters[MAX_SYSCALL_PARAMETERS]; } extended_syscall_info; Modified: haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp =================================================================== --- haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2008-02-07 15:09:19 UTC (rev 23915) +++ haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2008-02-07 16:03:00 UTC (rev 23916) @@ -419,6 +419,14 @@ file << "\t{" << endl; file << "\t\t\"" << syscall->Name() << "\", " << paramCount << "," << endl; + + // return type + Type* returnType = syscall->ReturnType(); + file << "\t\t{ " << returnType->Size() << ", " + << returnType->UsedSize() << ", " + << _GetTypeCode(returnType) << " }," << endl; + + // parameters file << "\t\t{" << endl; for (int k = 0; k < paramCount; k++) { From bonefish at mail.berlios.de Thu Feb 7 17:04:25 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 17:04:25 +0100 Subject: [Haiku-commits] r23917 - haiku/trunk/src/system/kernel Message-ID: <200802071604.m17G4Pbb024261@sheep.berlios.de> Author: bonefish Date: 2008-02-07 17:04:24 +0100 (Thu, 07 Feb 2008) New Revision: 23917 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23917&view=rev Modified: haiku/trunk/src/system/kernel/syscalls.cpp Log: Debug code. From time to time I still see 64 bit return values when they should be 32 bit only. Modified: haiku/trunk/src/system/kernel/syscalls.cpp =================================================================== --- haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-07 16:03:00 UTC (rev 23916) +++ haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-07 16:04:24 UTC (rev 23917) @@ -417,6 +417,13 @@ fReturnValue(returnValue) { Initialized(); +#if 0 + if (returnValue != (returnValue & 0xffffffff) + && kExtendedSyscallInfos[syscall].return_type.size <= 4) { + panic("syscall return value 64 bit although it should be 32 " + "bit"); + } +#endif } virtual void AddDump(TraceOutput& out) From bonefish at mail.berlios.de Thu Feb 7 20:04:39 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 20:04:39 +0100 Subject: [Haiku-commits] r23918 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802071904.m17J4dbJ000073@sheep.berlios.de> Author: bonefish Date: 2008-02-07 20:04:38 +0100 (Thu, 07 Feb 2008) New Revision: 23918 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23918&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S Log: Always clear the THREAD_FLAGS_64_BIT_SYSCALL_RETURN flag, even when using the int 99 syscall method. Otherwise it would remain set e.g. after _kern_restore_signal_frame() and the next syscall would look like one returning a 64 bit value. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-02-07 16:04:24 UTC (rev 23917) +++ haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-02-07 19:04:38 UTC (rev 23918) @@ -350,7 +350,8 @@ TRACE_POST_SYSCALL() testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ - | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ + | THREAD_FLAGS_64_BIT_SYSCALL_RETURN) \ , THREAD_flags(%edi) jnz post_syscall_work @@ -370,9 +371,10 @@ jmp pre_syscall_debug_done post_syscall_work_sysenter: + post_syscall_work: // if the 64 bit return value bit is set, we have to clear it testl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, THREAD_flags(%edi) - jz post_syscall_work + jz 2f 1: movl THREAD_flags(%edi), %eax movl %eax, %edx @@ -380,8 +382,8 @@ lock cmpxchgl %edx, THREAD_flags(%edi) jnz 1b + 2: - post_syscall_work: // post syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jz 1f From bonefish at mail.berlios.de Thu Feb 7 20:06:03 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 20:06:03 +0100 Subject: [Haiku-commits] r23919 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802071906.m17J63XP000830@sheep.berlios.de> Author: bonefish Date: 2008-02-07 20:06:03 +0100 (Thu, 07 Feb 2008) New Revision: 23919 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23919&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.c Log: Don't invalidate the syscall number, since that's not handled graciously in the syscall handler. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.c 2008-02-07 19:04:38 UTC (rev 23918) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.c 2008-02-07 19:06:03 UTC (rev 23919) @@ -508,8 +508,6 @@ TRACE(("### arch_restore_signal_frame: exit\n")); - frame->orig_eax = -1; /* disable syscall checks */ - return (int64)frame->eax | ((int64)frame->edx << 32); } From bonefish at mail.berlios.de Thu Feb 7 20:07:26 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 20:07:26 +0100 Subject: [Haiku-commits] r23920 - haiku/trunk/src/system/kernel Message-ID: <200802071907.m17J7Qu3001326@sheep.berlios.de> Author: bonefish Date: 2008-02-07 20:07:26 +0100 (Thu, 07 Feb 2008) New Revision: 23920 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23920&view=rev Modified: haiku/trunk/src/system/kernel/syscalls.cpp Log: Also check the syscall number to avoid problems. Modified: haiku/trunk/src/system/kernel/syscalls.cpp =================================================================== --- haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-07 19:06:03 UTC (rev 23919) +++ haiku/trunk/src/system/kernel/syscalls.cpp 2008-02-07 19:07:26 UTC (rev 23920) @@ -418,7 +418,8 @@ { Initialized(); #if 0 - if (returnValue != (returnValue & 0xffffffff) + if (syscall < (uint32)kSyscallCount + && returnValue != (returnValue & 0xffffffff) && kExtendedSyscallInfos[syscall].return_type.size <= 4) { panic("syscall return value 64 bit although it should be 32 " "bit"); From bonefish at mail.berlios.de Thu Feb 7 20:22:40 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 7 Feb 2008 20:22:40 +0100 Subject: [Haiku-commits] r23921 - in haiku/trunk: headers/private/kernel src/system/runtime_loader Message-ID: <200802071922.m17JMeQT003146@sheep.berlios.de> Author: bonefish Date: 2008-02-07 20:22:39 +0100 (Thu, 07 Feb 2008) New Revision: 23921 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23921&view=rev Modified: haiku/trunk/headers/private/kernel/tracing_config.h haiku/trunk/src/system/runtime_loader/elf.cpp Log: Added some kernel tracing to the runtime loader. Modified: haiku/trunk/headers/private/kernel/tracing_config.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-07 19:07:26 UTC (rev 23920) +++ haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-07 19:22:39 UTC (rev 23921) @@ -16,10 +16,11 @@ // macros that enable tracing for individual components +//#define BMESSAGE_TRACING //#define BLOCK_CACHE_TRANSACTION_TRACING +//#define RUNTIME_LOADER_TRACING //#define SIGNAL_TRACING //#define SYSCALL_TRACING //#define TEAM_TRACING -//#define BMESSAGE_TRACING #endif // KERNEL_TRACING_CONFIG_H Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-07 19:07:26 UTC (rev 23920) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-07 19:22:39 UTC (rev 23921) @@ -13,19 +13,20 @@ #include +#include +#include +#include + +#include #include +#include +#include +#include +#include #include -#include #include -#include -#include -#include -#include -#include -#include - //#define TRACE_RLD #ifdef TRACE_RLD # define TRACE(x) dprintf x @@ -112,6 +113,28 @@ #endif +#ifdef RUNTIME_LOADER_TRACING + +void +ktrace_printf(const char *format, ...) +{ + va_list list; + va_start(list, format); + + char buffer[1024]; + vsnprintf(buffer, sizeof(buffer), format, list); + _kern_ktrace_output(buffer); + + va_end(list); +} + +#define KTRACE(x...) ktrace_printf(x) + +#else +# define KTRACE(x...) +#endif // RUNTIME_LOADER_TRACING + + static void rld_unlock() { @@ -955,16 +978,22 @@ if (found) { atomic_add(&found->ref_count, 1); *_image = found; + KTRACE("rld: load_container(\"%s\", type: %d, rpath: \"%s\") " + "already loaded", name, type, rpath); return B_OK; } } + KTRACE("rld: load_container(\"%s\", type: %d, rpath: \"%s\")", name, type, + rpath); + strlcpy(path, name, sizeof(path)); // Try to load explicit image path first fd = open_executable(path, type, rpath); if (fd < 0) { FATAL("cannot open file %s\n", path); + KTRACE("rld: load_container(\"%s\"): failed to open file", name); return fd; } @@ -1000,6 +1029,8 @@ if (found) { atomic_add(&found->ref_count, 1); *_image = found; + KTRACE("rld: load_container(\"%s\"): already loaded after all", + name); return B_OK; } } @@ -1080,6 +1111,9 @@ sLoadedImageCount++; *_image = image; + + KTRACE("rld: load_container(\"%s\"): done: id: %ld", name, image->id); + return B_OK; err3: @@ -1088,6 +1122,10 @@ delete_image_struct(image); err1: _kern_close(fd); + + KTRACE("rld: load_container(\"%s\"): failed: %s", name, + strerror(status)); + return status; } @@ -1124,9 +1162,14 @@ if (image->num_needed == 0) return B_OK; + KTRACE("rld: load_dependencies(\"%s\", id: %ld)", image->name, + image->id); + image->needed = (image_t**)malloc(image->num_needed * sizeof(image_t *)); if (image->needed == NULL) { FATAL("failed to allocate needed struct\n"); + KTRACE("rld: load_dependencies(\"%s\", id: %ld) failed: no memory", + image->name, image->id); return B_NO_MEMORY; } @@ -1153,8 +1196,12 @@ } // Collect all missing libraries in case we report back - if (!reportErrors) + if (!reportErrors) { + KTRACE("rld: load_dependencies(\"%s\", id: %ld) " + "failed: %s", image->name, image->id, + strerror(status)); return status; + } } j += 1; @@ -1167,14 +1214,23 @@ } } - if (status < B_OK) + if (status < B_OK) { + KTRACE("rld: load_dependencies(\"%s\", id: %ld) " + "failed: %s", image->name, image->id, + strerror(status)); return status; + } if (j != image->num_needed) { FATAL("Internal error at load_dependencies()"); + KTRACE("rld: load_dependencies(\"%s\", id: %ld) " + "failed: internal error", image->name, image->id); return B_ERROR; } + KTRACE("rld: load_dependencies(\"%s\", id: %ld) done", image->name, + image->id); + return B_OK; } @@ -1297,6 +1353,8 @@ status_t status; image_t *image; + KTRACE("rld: load_program(\"%s\")", path); + rld_lock(); // for now, just do stupid simple global locking @@ -1348,9 +1406,15 @@ *_entry = (void *)(sProgramImage->entry_point); rld_unlock(); + + KTRACE("rld: load_program(\"%s\") done: entry: %p, id: %ld", path, + *_entry, sProgramImage->id); + return sProgramImage->id; err: + KTRACE("rld: load_program(\"%s\") failed: %s", path, strerror(status)); + delete_image(sProgramImage); if (report_errors()) { @@ -1383,6 +1447,8 @@ // ToDo: implement flags (void)flags; + KTRACE("rld: load_library(\"%s\", 0x%lx, %d)", path, flags, addOn); + rld_lock(); // for now, just do stupid simple global locking @@ -1393,6 +1459,8 @@ if (image) { atomic_add(&image->ref_count, 1); rld_unlock(); + KTRACE("rld: load_library(\"%s\"): already loaded: %ld", path, + image->id); return image->id; } } @@ -1400,6 +1468,8 @@ status = load_container(path, type, NULL, &image); if (status < B_OK) { rld_unlock(); + KTRACE("rld: load_library(\"%s\") failed to load container: %s", path, + strerror(status)); return status; } @@ -1417,9 +1487,14 @@ init_dependencies(image, true); rld_unlock(); + + KTRACE("rld: load_library(\"%s\") done: id: %ld", path, image->id); + return image->id; err: + KTRACE("rld: load_library(\"%s\") failed: %s", path, strerror(status)); + dequeue_image(&sLoadedImages, image); sLoadedImageCount--; delete_image(image); From korli at users.berlios.de Thu Feb 7 20:29:33 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Feb 2008 20:29:33 +0100 Subject: [Haiku-commits] r23889 - in haiku/trunk: build/jam headers/libs headers/libs/alm headers/libs/linprog src/libs src/libs/alm src/libs/linprog src/tests src/tests/libs src/tests/libs/alm src/tests/libs/linprog src/tests/libs/lp_solve In-Reply-To: <200802061051.m16Apjeo025382@sheep.berlios.de> References: <200802061051.m16Apjeo025382@sheep.berlios.de> Message-ID: Hi Ingo, could it be possible to include copyright headers for these files ? Thanks, J?r?me From korli at mail.berlios.de Thu Feb 7 20:31:49 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 7 Feb 2008 20:31:49 +0100 Subject: [Haiku-commits] r23922 - haiku/trunk/src/libs/alm Message-ID: <200802071931.m17JVnw7004012@sheep.berlios.de> Author: korli Date: 2008-02-07 20:31:49 +0100 (Thu, 07 Feb 2008) New Revision: 23922 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23922&view=rev Modified: haiku/trunk/src/libs/alm/Area.cpp Log: fix gcc4 build Modified: haiku/trunk/src/libs/alm/Area.cpp =================================================================== --- haiku/trunk/src/libs/alm/Area.cpp 2008-02-07 19:22:39 UTC (rev 23921) +++ haiku/trunk/src/libs/alm/Area.cpp 2008-02-07 19:31:49 UTC (rev 23922) @@ -15,6 +15,7 @@ #include // for max +using namespace std; BSize Area::kMaxSize(INT_MAX, INT_MAX); BSize Area::kMinSize(0, 0); From korli at mail.berlios.de Thu Feb 7 20:33:54 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 7 Feb 2008 20:33:54 +0100 Subject: [Haiku-commits] r23923 - haiku/trunk/src/bin Message-ID: <200802071933.m17JXs1a004303@sheep.berlios.de> Author: korli Date: 2008-02-07 20:33:53 +0100 (Thu, 07 Feb 2008) New Revision: 23923 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23923&view=rev Modified: haiku/trunk/src/bin/unmount.c Log: fix warning Modified: haiku/trunk/src/bin/unmount.c =================================================================== --- haiku/trunk/src/bin/unmount.c 2008-02-07 19:31:49 UTC (rev 23922) +++ haiku/trunk/src/bin/unmount.c 2008-02-07 19:33:53 UTC (rev 23923) @@ -9,9 +9,10 @@ #include #include -#include #include +#include #include +#include static void From ingo_weinhold at gmx.de Thu Feb 7 20:39:44 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 07 Feb 2008 20:39:44 +0100 Subject: [Haiku-commits] r23889 - in haiku/trunk: build/jam headers/libs headers/libs/alm headers/libs/linprog src/libs src/libs/alm src/libs/linprog src/tests src/tests/libs src/tests/libs/alm src/tests/libs/linprog src/tests/libs/lp_solve In-Reply-To: References: <200802061051.m16Apjeo025382@sheep.berlios.de> Message-ID: <20080207203944.459.1@knochen-vm.1202406206.fake> On 2008-02-07 at 20:29:33 [+0100], J?r?me Duval wrote: > > could it be possible to include copyright headers for these files ? I did already ask Christof. CU, Ingo From oruizdorantes at mail.berlios.de Thu Feb 7 20:56:09 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Thu, 7 Feb 2008 20:56:09 +0100 Subject: [Haiku-commits] r23924 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200802071956.m17Ju9ec006685@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-07 20:56:08 +0100 (Thu, 07 Feb 2008) New Revision: 23924 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23924&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h Log: Added remaining event IDs I saw in new Bluetooth 2.1 specs plus some internal stack haiku is gonna use Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-07 19:33:53 UTC (rev 23923) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-07 19:56:08 UTC (rev 23924) @@ -290,4 +290,41 @@ uint16 tx_packet_length; } __attribute__ ((packed)); -#endif \ No newline at end of file +// TODO: Define remaining Bluetooth 2.1 events structures +#define HCI_EVENT_EXTENDED_INQUIRY_RESULT 0x2F + +#define HCI_EVENT_ENCRYPTION_KEY_REFERSH_COMPLETE 0x30 + +#define HCI_EVENT_IO_CAPABILITY_REQUEST 0x31 + +#define HCI_EVENT_IO_CAPABILITY_RESPONSE 0x32 + +#define HCI_EVENT_USER_CONFIRMATION_REQUEST 0x33 + +#define HCI_EVENT_USER_PASSKEY_REQUEST 0x34 + +#define HCI_EVENT_OOB_DATA_REQUEST 0x35 + +#define HCI_EVENT_SIMPLE_PAIRING_COMPLETE 0x36 + +#define HCI_EVENT_LINK_SUPERVISION_TIMEOUT_CHANGED 0x38 + +#define HCI_EVENT_ENHANCED_FLUSH_COMPLETE 0x39 + +#define HCI_EVENT_KEYPRESS_NOTIFICATION 0x3C + +#define HCI_EVENT_REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION 0x3D + + + + +/* HAIKU Internal Events, not produced by the transport devices but + * by some entity of the Haiku Bluetooth Stack. + * The MSB 0xE is chosen for this purpose + */ + +#define HCI_HAIKU_EVENT_SERVER_QUITTING 0xE0 +#define HCI_HAIKU_EVENT_DEVICE_REMOVED 0xE1 + + +#endif From revol at free.fr Thu Feb 7 21:14:50 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Feb 2008 21:14:50 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23908_-_in_haiku/trunk/src/test?= =?windows-1252?q?s/apps=3A_=2E_terminal=5Freplicant?= In-Reply-To: <894b9700802070630l5fc539c3k80a31a9a12470239@mail.gmail.com> Message-ID: <1216933497-BeMail@laptop> > 2008/2/7, Michael Pfeiffer : > > > > Am 07.02.2008 um 14:29 schrieb jackburton at BerliOS: > > > > > Added a pretty useless test app to show that embedding a TermView > > > in > > > another apps works correctly (minus the blinking cursor, we'll > > > see why > > > it doesn't) > > > > Shouldn't the flags (B_WILL_DRAW | B_FRAME_EVENTS | > > B_FULL_UPDATE_ON_RESIZE > > | B_PULSE_NEEDED) also be set in the constructor > > TermView::TermView(BMessage *archive)? > > > > Yes, that was the cause, I noticed that too, I added them in > ::_InitObject(), called from every constructor. Please revert to the BMessageRunner if you want a replicant. Replicants live in someone else's BWindow and as such *must not* mess with its PulseRate(), meaning they have no control over it and since it's BWindow wide it cannot be used. Fran?ois. From korli at mail.berlios.de Thu Feb 7 21:21:33 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 7 Feb 2008 21:21:33 +0100 Subject: [Haiku-commits] r23925 - haiku/trunk/src/apps/midiplayer Message-ID: <200802072021.m17KLXxK010752@sheep.berlios.de> Author: korli Date: 2008-02-07 21:21:32 +0100 (Thu, 07 Feb 2008) New Revision: 23925 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23925&view=rev Modified: haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp Log: window is not zoomable, bug #1761 Modified: haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp =================================================================== --- haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp 2008-02-07 19:56:08 UTC (rev 23924) +++ haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp 2008-02-07 20:21:32 UTC (rev 23925) @@ -36,7 +36,7 @@ MidiPlayerWindow::MidiPlayerWindow() : BWindow(BRect(0, 0, 1, 1), "MIDI Player", B_TITLED_WINDOW, - B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE) + B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { playing = false; scopeEnabled = true; From mmlr at mail.berlios.de Fri Feb 8 00:19:29 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Fri, 8 Feb 2008 00:19:29 +0100 Subject: [Haiku-commits] r23926 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802072319.m17NJT6r002546@sheep.berlios.de> Author: mmlr Date: 2008-02-08 00:19:28 +0100 (Fri, 08 Feb 2008) New Revision: 23926 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23926&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c Log: Fix possible though unlikely SMP issue reported by Robert Szeleney. One must not use a single static variable to synchronize CPUs at two points. In an environment where CPUs do not really run concurently (in emulation or with logical processors) it would be possible for CPUs to get trapped in the first synchronization while another CPU might just do its thing and change the sync variable again. These CPUs would then never leave the first loop as the exit condition has already passed again. The key is to use two different sync variables like it is done in early kernel initialization. As I didn't manage to trigger this code though I am not sure if this is gonna work. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-02-07 20:21:32 UTC (rev 23925) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-02-07 23:19:28 UTC (rev 23926) @@ -66,7 +66,8 @@ void (*gX86SwapFPUFunc)(void *oldState, const void *newState); bool gHasSSE = false; -static vint32 sWaitAllCPUs; +static uint32 sCpuRendezvous; +static uint32 sCpuRendezvous2; segment_descriptor *gGDT = NULL; @@ -114,9 +115,7 @@ struct set_mtrr_parameter *parameter = (struct set_mtrr_parameter *)_parameter; // wait until all CPUs have arrived here - atomic_add(&sWaitAllCPUs, 1); - while (sWaitAllCPUs != smp_get_num_cpus()) - asm volatile ("pause;"); + smp_cpu_rendezvous(&sCpuRendezvous, cpu); disable_caches(); @@ -126,9 +125,7 @@ enable_caches(); // wait until all CPUs have arrived here - atomic_add(&sWaitAllCPUs, -1); - while (sWaitAllCPUs != 0) - asm volatile ("pause;"); + smp_cpu_rendezvous(&sCpuRendezvous2, cpu); } @@ -136,9 +133,7 @@ init_mtrrs(void *_unused, int cpu) { // wait until all CPUs have arrived here - atomic_add(&sWaitAllCPUs, 1); - while (sWaitAllCPUs != smp_get_num_cpus()) - asm volatile ("pause;"); + smp_cpu_rendezvous(&sCpuRendezvous, cpu); disable_caches(); @@ -147,9 +142,7 @@ enable_caches(); // wait until all CPUs have arrived here - atomic_add(&sWaitAllCPUs, -1); - while (sWaitAllCPUs != 0) - asm volatile ("pause;"); + smp_cpu_rendezvous(&sCpuRendezvous2, cpu); } @@ -174,6 +167,7 @@ parameter.length = length; parameter.type = type; + sCpuRendezvous = sCpuRendezvous2 = 0; call_all_cpus(&set_mtrr, ¶meter); } @@ -549,8 +543,10 @@ close_module_list(cookie); // initialize MTRRs if available - if (x86_count_mtrrs() > 0) + if (x86_count_mtrrs() > 0) { + sCpuRendezvous = sCpuRendezvous2 = 0; call_all_cpus(&init_mtrrs, NULL); + } // get optimized functions from the CPU module if (sCpuModule != NULL && sCpuModule->get_optimized_functions != NULL) { From colacoder at mail.berlios.de Fri Feb 8 01:34:54 2008 From: colacoder at mail.berlios.de (colacoder at BerliOS) Date: Fri, 8 Feb 2008 01:34:54 +0100 Subject: [Haiku-commits] r23927 - in haiku/trunk: headers/private/print src/servers/print Message-ID: <200802080034.m180YsMv028654@sheep.berlios.de> Author: colacoder Date: 2008-02-08 01:34:53 +0100 (Fri, 08 Feb 2008) New Revision: 23927 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23927&view=rev Added: haiku/trunk/src/servers/print/Transport.Scripting.cpp haiku/trunk/src/servers/print/Transport.cpp haiku/trunk/src/servers/print/Transport.h Modified: haiku/trunk/headers/private/print/PrintTransportAddOn.h haiku/trunk/src/servers/print/Jamfile haiku/trunk/src/servers/print/PrintServerApp.Scripting.cpp haiku/trunk/src/servers/print/PrintServerApp.cpp haiku/trunk/src/servers/print/PrintServerApp.h Log: Make print_server track Transport addons too. This is because some of the NewTransportAddOns(tm) can also autodetect devices, e.g. USB printers. For this, the print_server needs to keep those transport addons loaded at all times. This code now also enables dynamic Transport discovery for the Printer prefs, e.g. 'hey print_server GET Transport 0' or 'hey print_server GET Transport 'USB Port'' will now work too ;) Modified: haiku/trunk/headers/private/print/PrintTransportAddOn.h =================================================================== --- haiku/trunk/headers/private/print/PrintTransportAddOn.h 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/headers/private/print/PrintTransportAddOn.h 2008-02-08 00:34:53 UTC (rev 23927) @@ -35,8 +35,18 @@ #include #include +// int transport_features; symbol name +#define B_TRANSPORT_FEATURES_SYMBOL "transport_features" + +// Bit values for 'transport_features' +enum { + B_TRANSPORT_SUPPORTS_PROBE = 1, + B_TRANSPORT_SUPPORTS_SHARING = 2, +}; + // to be implemented by the transport add-on extern "C" BDataIO* instantiate_transport(BDirectory* printer, BMessage* msg); +extern "C" status_t install_transport_probe(void); #endif Modified: haiku/trunk/src/servers/print/Jamfile =================================================================== --- haiku/trunk/src/servers/print/Jamfile 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/Jamfile 2008-02-08 00:34:53 UTC (rev 23927) @@ -7,6 +7,7 @@ SubDir HAIKU_TOP src servers print ; UsePrivateHeaders shared interface print ; +UsePrivateHeaders print ; AddResources print_server @@ -22,6 +23,8 @@ PrintServerApp.Scripting.cpp Printer.Scripting.cpp Printer.cpp + Transport.Scripting.cpp + Transport.cpp ResourceManager.cpp Settings.cpp ConfigWindow.cpp Modified: haiku/trunk/src/servers/print/PrintServerApp.Scripting.cpp =================================================================== --- haiku/trunk/src/servers/print/PrintServerApp.Scripting.cpp 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/PrintServerApp.Scripting.cpp 2008-02-08 00:34:53 UTC (rev 23927) @@ -7,6 +7,7 @@ */ #include "PrintServerApp.h" +#include "Transport.h" #include "Printer.h" // BeOS API @@ -26,6 +27,10 @@ "Delete a specific printer" }, { "Printers", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER }, "Return the number of available printers" }, + { "Transport", { B_GET_PROPERTY }, { B_INDEX_SPECIFIER, B_NAME_SPECIFIER, B_REVERSE_INDEX_SPECIFIER }, + "Retrieve a specific transport" }, + { "Transports", { B_COUNT_PROPERTIES }, { B_DIRECT_SPECIFIER }, + "Return the number of available transports" }, { "UseConfigWindow", { B_GET_PROPERTY, B_SET_PROPERTY }, { B_DIRECT_SPECIFIER }, "Show configuration window" }, { 0 } // terminate list @@ -110,6 +115,11 @@ reply.AddInt32("result", Printer::CountPrinters()); reply.AddInt32("error", B_OK); msg->SendReply(&reply); + } else if (propName == "Transports") { + BMessage reply(B_REPLY); + reply.AddInt32("result", Transport::CountTransports()); + reply.AddInt32("error", B_OK); + msg->SendReply(&reply); } break; } @@ -147,13 +157,44 @@ return NULL; } +Transport* PrintServerApp::GetTransportFromSpecifier(BMessage* msg) +{ + switch(msg->what) { + case B_NAME_SPECIFIER: { + BString name; + if (msg->FindString("name", &name) == B_OK) { + return Transport::Find(name); + } + break; + } + + case B_INDEX_SPECIFIER: { + int32 idx; + if (msg->FindInt32("index", &idx) == B_OK) { + return Transport::At(idx); + } + break; + } + + case B_REVERSE_INDEX_SPECIFIER: { + int32 idx; + if (msg->FindInt32("index", &idx) == B_OK) { + return Transport::At(Transport::CountTransports() - idx); + } + break; + } + } + + return NULL; +} + BHandler* PrintServerApp::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, int32 form, const char* prop) { BPropertyInfo prop_info(prop_list); BHandler* rc = NULL; - + int32 idx; switch( idx=prop_info.FindMatch(msg,0,spec,form,prop) ) { case B_ERROR: @@ -170,6 +211,17 @@ msg->PopSpecifier(); break; + // GET Transport [arg] + case 5: + if ((rc=GetTransportFromSpecifier(spec)) == NULL) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_BAD_INDEX); + msg->SendReply(&reply); + } + else + msg->PopSpecifier(); + break; + default: rc = this; } Modified: haiku/trunk/src/servers/print/PrintServerApp.cpp =================================================================== --- haiku/trunk/src/servers/print/PrintServerApp.cpp 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/PrintServerApp.cpp 2008-02-08 00:34:53 UTC (rev 23927) @@ -11,6 +11,7 @@ #include "BeUtils.h" #include "Printer.h" #include "pr_server.h" +#include "Transport.h" // BeOS API #include @@ -90,6 +91,11 @@ fHasReferences = create_sem(1, "has_references"); + // Build list of transport addons + Transport::Scan(B_USER_ADDONS_DIRECTORY); + Transport::Scan(B_COMMON_ADDONS_DIRECTORY); + Transport::Scan(B_BEOS_ADDONS_DIRECTORY); + SetupPrinterList(); RetrieveDefaultPrinter(); Modified: haiku/trunk/src/servers/print/PrintServerApp.h =================================================================== --- haiku/trunk/src/servers/print/PrintServerApp.h 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/PrintServerApp.h 2008-02-08 00:34:53 UTC (rev 23927) @@ -19,6 +19,7 @@ #include "Settings.h" class Printer; +class Transport; // The global BLocker for synchronisation. extern BLocker *gLock; @@ -43,6 +44,7 @@ status_t GetSupportedSuites(BMessage *msg); void HandleScriptingCommand(BMessage *msg); Printer *GetPrinterFromSpecifier(BMessage *msg); + Transport *GetTransportFromSpecifier(BMessage *msg); BHandler *ResolveSpecifier(BMessage *msg, int32 index, BMessage *spec, int32 form, const char *prop); private: Added: haiku/trunk/src/servers/print/Transport.Scripting.cpp =================================================================== --- haiku/trunk/src/servers/print/Transport.Scripting.cpp 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/Transport.Scripting.cpp 2008-02-08 00:34:53 UTC (rev 23927) @@ -0,0 +1,84 @@ +/* + * Copyright 2008, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include "Transport.h" + +// BeOS API +#include +#include +#include +#include + +static property_info prop_list[] = { + { "Name", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, + "Get name of transport" }, + { 0 } // terminate list +}; + +void Transport::HandleScriptingCommand(BMessage* msg) +{ + status_t rc = B_ERROR; + BString propName; + BString result; + BMessage spec; + int32 idx; + + if ((rc=msg->GetCurrentSpecifier(&idx,&spec)) == B_OK && + (rc=spec.FindString("property",&propName)) == B_OK) { + switch(msg->what) { + case B_GET_PROPERTY: + if (propName == "Name") + result = fName; + else { // If unknown scripting request, let superclas handle it + Inherited::MessageReceived(msg); + break; + } + + BMessage reply(B_REPLY); + reply.AddString("result", result); + reply.AddInt32("error", rc); + msg->SendReply(&reply); + break; + } + } + else { + // If GetSpecifier failed + if (idx == -1) { + BMessage reply(B_REPLY); + reply.AddMessenger("result", BMessenger(this)); + reply.AddInt32("error", B_OK); + msg->SendReply(&reply); + } + } +} + +BHandler* Transport::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, + int32 form, const char* prop) +{ + BPropertyInfo prop_info(prop_list); + BHandler* rc = this; + + int32 idx; + switch( idx=prop_info.FindMatch(msg,0,spec,form,prop) ) { + case B_ERROR: + rc = Inherited::ResolveSpecifier(msg,index,spec,form,prop); + break; + } + + return rc; +} + +status_t Transport::GetSupportedSuites(BMessage* msg) +{ + msg->AddString("suites", "application/x-vnd.OpenBeOS-transport"); + + BPropertyInfo prop_info(prop_list); + msg->AddFlat("messages", &prop_info); + + return Inherited::GetSupportedSuites(msg); +} Added: haiku/trunk/src/servers/print/Transport.cpp =================================================================== --- haiku/trunk/src/servers/print/Transport.cpp 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/Transport.cpp 2008-02-08 00:34:53 UTC (rev 23927) @@ -0,0 +1,174 @@ +/* + * Copyright 2008, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include "Transport.h" + +// BeOS API +#include +#include +#include +#include + +// --------------------------------------------------------------- +BObjectList Transport::sTransports; + +// --------------------------------------------------------------- +// Find [static] +// +// Searches the static object list for a transport object with the +// specified name. +// +// Parameters: +// name - Printer definition name we're looking for. +// +// Returns: +// Pointer to Transport object, or NULL if not found. +// --------------------------------------------------------------- +Transport* Transport::Find(const BString& name) +{ + // Look in list to find printer definition + for (int32 idx=0; idx < sTransports.CountItems(); idx++) { + if (name == sTransports.ItemAt(idx)->Name()) { + return sTransports.ItemAt(idx); + } + } + + // None found, so return NULL + return NULL; +} + +// --------------------------------------------------------------- +Transport* Transport::At(int32 idx) +{ + return sTransports.ItemAt(idx); +} + +// --------------------------------------------------------------- +void Transport::Remove(Transport* transport) +{ + sTransports.RemoveItem(transport); +} + +// --------------------------------------------------------------- +int32 Transport::CountTransports() +{ + return sTransports.CountItems(); +} + +// --------------------------------------------------------------- +status_t Transport::Scan(directory_which which) +{ + BDirectory dir; + status_t rc; + BPath path; + + // Try to find specified transport addon directory + if ((rc=find_directory(which,&path)) != B_OK) + return rc; + + if ((rc=path.Append("Print/transport")) != B_OK) + return rc; + + if ((rc=dir.SetTo(path.Path())) != B_OK) + return rc; + + // Walk over all entries in directory + BEntry entry; + while(dir.GetNextEntry(&entry) == B_OK) { + if (!entry.IsFile()) + continue; + + if (entry.GetPath(&path) != B_OK) + continue; + + // If we have loaded the transport from a previous scanned directory, + // ignore this one. + if (Transport::Find(path.Leaf()) != NULL) + continue; + + be_app->AddHandler(new Transport(path)); + } + + return B_OK; + +} + +// --------------------------------------------------------------- +// Transport [constructor] +// +// Initializes the transport object with data read from the +// attributes attached to the printer definition node. +// +// Parameters: +// node - Printer definition node for this printer. +// +// Returns: +// none. +// --------------------------------------------------------------- +Transport::Transport(const BPath& path) + : BHandler(B_EMPTY_STRING), + fName(path.Leaf()), + fImageID(-1), + fFeatures(0) +{ + // Load transport addon + image_id id = ::load_add_on(path.Path()); + if (id < B_OK) + return; + + // Find transport_features symbol, to determine if we need to keep + // this transport loaded + int* transport_features_ptr; + if (get_image_symbol(id, B_TRANSPORT_FEATURES_SYMBOL, + B_SYMBOL_TYPE_DATA, (void**)&transport_features_ptr) != B_OK) { + unload_add_on(id); + } else { + fFeatures = *transport_features_ptr; + + if (*transport_features_ptr & B_TRANSPORT_SUPPORTS_PROBE) { + // Transport supports probing, so it needs to stay loaded... + printf("IRA: Transport %s supports probing!\n", path.Path()); + fImageID = id; + } + else // No extended Transport support; so no need to keep loaded + ::unload_add_on(id); + } + + sTransports.AddItem(this); +} + +// --------------------------------------------------------------- +Transport::~Transport() +{ + sTransports.RemoveItem(this); +} + +// --------------------------------------------------------------- +// MessageReceived +// +// Handle scripting messages. +// +// Parameters: +// msg - message. +// --------------------------------------------------------------- +void Transport::MessageReceived(BMessage* msg) +{ + switch(msg->what) { + case B_GET_PROPERTY: + case B_SET_PROPERTY: + case B_CREATE_PROPERTY: + case B_DELETE_PROPERTY: + case B_COUNT_PROPERTIES: + case B_EXECUTE_PROPERTY: + HandleScriptingCommand(msg); + break; + + default: + Inherited::MessageReceived(msg); + } +} Added: haiku/trunk/src/servers/print/Transport.h =================================================================== --- haiku/trunk/src/servers/print/Transport.h 2008-02-07 23:19:28 UTC (rev 23926) +++ haiku/trunk/src/servers/print/Transport.h 2008-02-08 00:34:53 UTC (rev 23927) @@ -0,0 +1,52 @@ +/* + * Copyright 2008, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ +#ifndef TRANSPORT_H +#define TRANSPORT_H + +class Transport; + +#include +#include +#include +#include + +#include + +class Transport : public BHandler +{ + typedef BHandler Inherited; +public: + Transport(const BPath& path); + ~Transport(); + + const BString& Name() const { return fName; } + + static status_t Scan(directory_which which); + + static Transport* Find(const BString& name); + static void Remove(Transport* transport); + static Transport* At(int32 idx); + static int32 CountTransports(); + + void MessageReceived(BMessage* msg); + + // Scripting support, see Printer.Scripting.cpp + status_t GetSupportedSuites(BMessage* msg); + void HandleScriptingCommand(BMessage* msg); + BHandler* ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, + int32 form, const char* prop); + +private: + BString fName; + long fImageID; + int fFeatures; + + static BObjectList sTransports; +}; + +#endif From colacoder at mail.berlios.de Fri Feb 8 03:00:09 2008 From: colacoder at mail.berlios.de (colacoder at BerliOS) Date: Fri, 8 Feb 2008 03:00:09 +0100 Subject: [Haiku-commits] r23928 - in haiku/trunk: headers/private/print src/servers/print Message-ID: <200802080200.m18209xm003336@sheep.berlios.de> Author: colacoder Date: 2008-02-08 03:00:08 +0100 (Fri, 08 Feb 2008) New Revision: 23928 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23928&view=rev Modified: haiku/trunk/headers/private/print/PrintTransportAddOn.h haiku/trunk/src/servers/print/Transport.Scripting.cpp haiku/trunk/src/servers/print/Transport.cpp haiku/trunk/src/servers/print/Transport.h Log: Slight rework of my previous commit... now ports can be asked too ;) Modified: haiku/trunk/headers/private/print/PrintTransportAddOn.h =================================================================== --- haiku/trunk/headers/private/print/PrintTransportAddOn.h 2008-02-08 00:34:53 UTC (rev 23927) +++ haiku/trunk/headers/private/print/PrintTransportAddOn.h 2008-02-08 02:00:08 UTC (rev 23928) @@ -35,18 +35,18 @@ #include #include -// int transport_features; symbol name +#define B_TRANSPORT_LIST_PORTS_SYMBOL "list_transport_ports" #define B_TRANSPORT_FEATURES_SYMBOL "transport_features" // Bit values for 'transport_features' enum { - B_TRANSPORT_SUPPORTS_PROBE = 1, - B_TRANSPORT_SUPPORTS_SHARING = 2, + B_TRANSPORT_IS_HOTPLUG = 1, + B_TRANSPORT_IS_NETWORK = 2, }; // to be implemented by the transport add-on extern "C" BDataIO* instantiate_transport(BDirectory* printer, BMessage* msg); -extern "C" status_t install_transport_probe(void); +extern "C" status_t list_transport_ports(BMessage* msg); #endif Modified: haiku/trunk/src/servers/print/Transport.Scripting.cpp =================================================================== --- haiku/trunk/src/servers/print/Transport.Scripting.cpp 2008-02-08 00:34:53 UTC (rev 23927) +++ haiku/trunk/src/servers/print/Transport.Scripting.cpp 2008-02-08 02:00:08 UTC (rev 23928) @@ -17,6 +17,8 @@ static property_info prop_list[] = { { "Name", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, "Get name of transport" }, + { "Ports", { B_GET_PROPERTY }, { B_DIRECT_SPECIFIER }, + "Get currently available ports/devices" }, { 0 } // terminate list }; @@ -33,8 +35,16 @@ switch(msg->what) { case B_GET_PROPERTY: if (propName == "Name") - result = fName; - else { // If unknown scripting request, let superclas handle it + result = Name(); + else if (propName == "Ports") { + // Need to duplicate messaging code, as our result is a complex + // bmessage, not a string :( + BMessage reply(B_REPLY); + rc = ListAvailablePorts(&reply); + reply.AddInt32("error", rc); + msg->SendReply(&reply); + break; + } else { // If unknown scripting request, let superclas handle it Inherited::MessageReceived(msg); break; } Modified: haiku/trunk/src/servers/print/Transport.cpp =================================================================== --- haiku/trunk/src/servers/print/Transport.cpp 2008-02-08 00:34:53 UTC (rev 23927) +++ haiku/trunk/src/servers/print/Transport.cpp 2008-02-08 02:00:08 UTC (rev 23928) @@ -112,7 +112,7 @@ // --------------------------------------------------------------- Transport::Transport(const BPath& path) : BHandler(B_EMPTY_STRING), - fName(path.Leaf()), + fPath(path), fImageID(-1), fFeatures(0) { @@ -130,9 +130,8 @@ } else { fFeatures = *transport_features_ptr; - if (*transport_features_ptr & B_TRANSPORT_SUPPORTS_PROBE) { - // Transport supports probing, so it needs to stay loaded... - printf("IRA: Transport %s supports probing!\n", path.Path()); + if (*transport_features_ptr & B_TRANSPORT_IS_HOTPLUG) { + // We are hotpluggable; so keep us loaded! fImageID = id; } else // No extended Transport support; so no need to keep loaded @@ -149,6 +148,33 @@ } // --------------------------------------------------------------- +status_t Transport::ListAvailablePorts(BMessage* msg) +{ + status_t (*list_ports)(BMessage*); + image_id id = fImageID; + status_t rc = B_OK; + + // Load image if not loaded yet + if (id == -1 && (id=load_add_on(fPath.Path())) < 0) + return id; + + // Get pointer to addon function + if ((rc=get_image_symbol(id, B_TRANSPORT_LIST_PORTS_SYMBOL, + B_SYMBOL_TYPE_TEXT, (void**)&list_ports)) != B_OK) + goto done; + + // run addon... + rc = (*list_ports)(msg); + +done: + // clean up if needed + if (fImageID != id) + unload_add_on(id); + + return rc; +} + +// --------------------------------------------------------------- // MessageReceived // // Handle scripting messages. Modified: haiku/trunk/src/servers/print/Transport.h =================================================================== --- haiku/trunk/src/servers/print/Transport.h 2008-02-08 00:34:53 UTC (rev 23927) +++ haiku/trunk/src/servers/print/Transport.h 2008-02-08 02:00:08 UTC (rev 23928) @@ -24,8 +24,10 @@ Transport(const BPath& path); ~Transport(); - const BString& Name() const { return fName; } + BString Name() const { return fPath.Leaf(); } + status_t ListAvailablePorts(BMessage* msg); + static status_t Scan(directory_which which); static Transport* Find(const BString& name); @@ -42,7 +44,7 @@ int32 form, const char* prop); private: - BString fName; + BPath fPath; long fImageID; int fFeatures; From bonefish at mail.berlios.de Fri Feb 8 04:06:15 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 8 Feb 2008 04:06:15 +0100 Subject: [Haiku-commits] r23929 - in haiku/trunk: headers/private/kernel src/system/kernel/fs Message-ID: <200802080306.m1836Fg2006606@sheep.berlios.de> Author: bonefish Date: 2008-02-08 04:06:14 +0100 (Fri, 08 Feb 2008) New Revision: 23929 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23929&view=rev Modified: haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Added new syscall _kern_normalize_path() to normalize a path. Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-02-08 02:00:08 UTC (rev 23928) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-02-08 03:06:14 UTC (rev 23929) @@ -143,6 +143,8 @@ extern status_t _kern_sync(void); extern status_t _kern_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf, char *userPath, size_t pathLength); +extern status_t _kern_normalize_path(const char* userPath, + bool traverseLink, char* buffer); extern int _kern_open_entry_ref(dev_t device, ino_t inode, const char *name, int openMode, int perms); extern int _kern_open(int fd, const char *path, int openMode, int perms); extern int _kern_open_dir_entry_ref(dev_t device, ino_t inode, const char *name); Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2008-02-08 02:00:08 UTC (rev 23928) +++ haiku/trunk/headers/private/kernel/vfs.h 2008-02-08 03:06:14 UTC (rev 23929) @@ -137,6 +137,8 @@ size_t infoSize); status_t _user_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf, char *userPath, size_t pathLength); +status_t _user_normalize_path(const char* userPath, bool traverseLink, + char* buffer); int _user_open_entry_ref(dev_t device, ino_t inode, const char *name, int openMode, int perms); int _user_open(int fd, const char *path, int openMode, int perms); int _user_open_dir_node_ref(dev_t device, ino_t inode); Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-08 02:00:08 UTC (rev 23928) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-08 03:06:14 UTC (rev 23929) @@ -1908,6 +1908,52 @@ } +/*! \brief Retrieves the directory vnode and the leaf name of an entry referred + to by a vnode + path pair. + + \a path must be given in either case. \a vnode might be omitted, in which + case \a path is either an absolute path or one relative to the current + directory. If both a supplied and \a path is relative it is reckoned off + of the directory referred to by \a vnode. If \a path is absolute \a vnode is + ignored. + + The caller has the responsibility to call put_vnode() on the returned + directory vnode. + + \param vnode The vnode. May be \c NULL. + \param path The absolute or relative path. Must not be \c NULL. The buffer + is modified by this function. It must have at least room for a + string one character longer than the path it contains. + \param _vnode A pointer to a variable the directory vnode shall be written + into. + \param filename A buffer of size B_FILE_NAME_LENGTH or larger into which + the leaf name of the specified entry will be written. + \param kernel \c true, if invoked from inside the kernel, \c false if + invoked from userland. + \return \c B_OK, if everything went fine, another error code otherwise. +*/ +static status_t +vnode_and_path_to_dir_vnode(struct vnode* vnode, char *path, + struct vnode **_vnode, char *filename, bool kernel) +{ + if (!path) + return B_BAD_VALUE; + if (*path == '\0') + return B_ENTRY_NOT_FOUND; + if (vnode == NULL) + return path_to_dir_vnode(path, _vnode, filename, kernel); + + status_t status = get_dir_path_and_leaf(path, filename); + if (status != B_OK) + return status; + + inc_vnode_ref_count(vnode); + // vnode_path_to_vnode() always decrements the ref count + + return vnode_path_to_vnode(vnode, path, true, 0, _vnode, NULL, NULL); +} + + /*! Returns a vnode's name in the d_name field of a supplied dirent buffer. */ static status_t @@ -3297,6 +3343,7 @@ \param path The path to be normalized. \param buffer The buffer into which the normalized path will be written. + May be the same one as \a path. \param bufferSize The size of \a buffer. \param kernel \c true, if the IO context of the kernel shall be used, otherwise that of the team this thread belongs to. Only relevant, @@ -7178,6 +7225,113 @@ } +status_t +_user_normalize_path(const char* userPath, bool traverseLink, char* buffer) +{ + if (userPath == NULL || buffer == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userPath) || !IS_USER_ADDRESS(buffer)) + return B_BAD_ADDRESS; + + // copy path from userland + KPath pathBuffer(B_PATH_NAME_LENGTH + 1); + if (pathBuffer.InitCheck() != B_OK) + return B_NO_MEMORY; + char* path = pathBuffer.LockBuffer(); + + if (user_strlcpy(path, userPath, B_PATH_NAME_LENGTH) < B_OK) + return B_BAD_ADDRESS; + + // buffer for the leaf part + KPath leafBuffer(B_PATH_NAME_LENGTH + 1); + if (leafBuffer.InitCheck() != B_OK) + return B_NO_MEMORY; + char* leaf = leafBuffer.LockBuffer(); + + VNodePutter dirPutter; + struct vnode* dir = NULL; + status_t error; + + for (int i = 0; i < B_MAX_SYMLINKS; i++) { + // get dir vnode + leaf name + struct vnode* nextDir; + error = vnode_and_path_to_dir_vnode(dir, path, &nextDir, leaf, false); + if (error != B_OK) + return error; + + dir = nextDir; + strcpy(path, leaf); + dirPutter.SetTo(dir); + + // get file vnode + inc_vnode_ref_count(dir); + struct vnode* fileVnode; + int type; + error = vnode_path_to_vnode(dir, path, false, 0, &fileVnode, NULL, + &type); + if (error != B_OK) + return error; + VNodePutter fileVnodePutter(fileVnode); + + if (!traverseLink || !S_ISLNK(type)) { + // we're done -- construct the path + bool hasLeaf = true; + if (strcmp(leaf, ".") == 0 || strcmp(leaf, "..") == 0) { + // special cases "." and ".." -- get the dir, forget the leaf + inc_vnode_ref_count(dir); + error = vnode_path_to_vnode(dir, leaf, false, 0, &nextDir, NULL, + NULL); + if (error != B_OK) + return error; + dir = nextDir; + dirPutter.SetTo(dir); + hasLeaf = false; + } + + // get the directory path + error = dir_vnode_to_path(dir, path, B_PATH_NAME_LENGTH); + if (error != B_OK) + return error; + + // append the leaf name + if (hasLeaf) { + // insert a directory separator if this is not the file system + // root + if ((strcmp(path, "/") != 0 + && strlcat(path, "/", pathBuffer.BufferSize()) + >= pathBuffer.BufferSize()) + || strlcat(path, leaf, pathBuffer.BufferSize()) + >= pathBuffer.BufferSize()) { + return B_NAME_TOO_LONG; + } + } + + // copy back to userland + int len = user_strlcpy(buffer, path, B_PATH_NAME_LENGTH); + if (len < 0) + return len; + if (len >= B_PATH_NAME_LENGTH) + return B_BUFFER_OVERFLOW; + + return B_OK; + } + + // read link + struct stat st; + if (FS_CALL(fileVnode, read_symlink) != NULL) { + size_t bufferSize = B_PATH_NAME_LENGTH; + error = FS_CALL(fileVnode, read_symlink)(fileVnode->mount->cookie, + fileVnode->private_node, path, &bufferSize); + if (error != B_OK) + return error; + } else + return B_BAD_VALUE; + } + + return B_LINK_LIMIT; +} + + int _user_open_entry_ref(dev_t device, ino_t inode, const char *userName, int openMode, int perms) From bonefish at mail.berlios.de Fri Feb 8 04:18:28 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 8 Feb 2008 04:18:28 +0100 Subject: [Haiku-commits] r23930 - haiku/trunk/src/system/runtime_loader Message-ID: <200802080318.m183ISnJ007309@sheep.berlios.de> Author: bonefish Date: 2008-02-08 04:18:26 +0100 (Fri, 08 Feb 2008) New Revision: 23930 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23930&view=rev Modified: haiku/trunk/src/system/runtime_loader/elf.cpp Log: Normalize the given image path in load_container(). Just constructing some absolute path was not enough to always recognize a library as already loaded. This fixes problems with Perl where loading an add-on would cause another instance of libperl.so to be loaded, which would lead to crashes due to uninitialized static vars in the new instance. Perl builds now and the tests run, but quite a few do fail. Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-08 03:06:14 UTC (rev 23929) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-08 03:18:26 UTC (rev 23930) @@ -997,30 +997,11 @@ return fd; } - // If the path is not absolute, we prepend the CWD to make it one. - if (path[0] != '/') { - char relativePath[PATH_MAX]; - if (!strncmp(path, "./", 2)) - strcpy(relativePath, path + 2); - else - strcpy(relativePath, path); + // normalize the image path + status = _kern_normalize_path(path, true, path); + if (status != B_OK) + goto err1; - // get the CWD - status = _kern_getcwd(path, sizeof(path)); - if (status < B_OK) { - FATAL("_kern_getcwd() failed\n"); - goto err1; - } - - if (strlcat(path, "/", sizeof(path)) >= sizeof(path) - || strlcat(path, relativePath, sizeof(path)) >= sizeof(path)) { - status = B_NAME_TOO_LONG; - FATAL("Absolute path of image %s is too " - "long!\n", relativePath); - goto err1; - } - } - // Test again if this image has been registered already - this time, // we can check the full path, not just its name as noted. // You could end up loading an image twice with symbolic links, else. From stefano.ceccherini at gmail.com Fri Feb 8 08:48:04 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Fri, 8 Feb 2008 08:48:04 +0100 Subject: [Haiku-commits] r23908 - in haiku/trunk/src/tests/apps: . terminal_replicant In-Reply-To: <1216933497-BeMail@laptop> References: <894b9700802070630l5fc539c3k80a31a9a12470239@mail.gmail.com> <1216933497-BeMail@laptop> Message-ID: <894b9700802072348lfeeb06cu4f5e21c18a43d1a0@mail.gmail.com> 2008/2/7, Fran?ois Revol : > > Yes, that was the cause, I noticed that too, I added them in > > ::_InitObject(), called from every constructor. > > Please revert to the BMessageRunner if you want a replicant. It's not a case of "reverting", since it never used a BMessageRunner in the first place :) > Replicants live in someone else's BWindow and as such *must not* mess > with its PulseRate(), meaning they have no control over it and since > it's BWindow wide it cannot be used. I already use a BMessageRunner for the sigwinch handler for that reason, but then I seen some other replicants which use pulse so I thought it wasn't a big deal and implemented cursor blinking using pulse. But you are right: I'll use another BMessageRunner. From jackburton at mail.berlios.de Fri Feb 8 13:16:50 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 8 Feb 2008 13:16:50 +0100 Subject: [Haiku-commits] r23931 - haiku/trunk/src/apps/terminal Message-ID: <200802081216.m18CGo6E030228@sheep.berlios.de> Author: jackburton Date: 2008-02-08 13:16:49 +0100 (Fri, 08 Feb 2008) New Revision: 23931 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23931&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Moved call to SetSteps() from SetTermSize() to FrameResized(), where it makes more sense (and also completes the fix for bug #1759). Retrieve the command from the message archive. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-08 03:18:26 UTC (rev 23930) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-02-08 12:16:49 UTC (rev 23931) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku, Inc. + * Copyright 2001-2008, Haiku, Inc. * Copyright 2003-2004 Kian Duffy, myob at users.sourceforge.net * Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai. * All rights reserved. Distributed under the terms of the MIT license. @@ -228,6 +228,9 @@ fMouseTracking(false), fIMflag(false) { + // We need this + SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); + if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK) fEncoding = M_UTF8; if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK) @@ -235,11 +238,19 @@ if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK) fTermRows = ROWS_DEFAULT; - // We need this - SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED); + int32 argc = 0; + if (archive->HasInt32("argc")) + archive->FindInt32("argc", &argc); + + const char **argv = new const char*[argc]; + for (int32 i = 0; i < argc; i++) { + archive->FindString("argv", i, (const char **)&argv[i]); + } - // TODO: Retrieve arguments, colors, history size, etc. from archive - _InitObject(0, NULL); + // TODO: Retrieve colors, history size, etc. from archive + _InitObject(argc, argv); + + delete[] argv; } @@ -364,9 +375,6 @@ if (resize) ResizeTo(rect.Width(), rect.Height()); - - if (fScrollBar != NULL) - fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); return rect; } @@ -1285,6 +1293,10 @@ BMessage message(kUpdateSigWinch); fWinchRunner = new (std::nothrow) BMessageRunner(BMessenger(this), &message, 500000); + // TODO: Since we can also be a replicant, messing + // with the window, which is not ours, is not nice: + // Switch to using a BMessageRunner for the + // blinking caret too. Window()->SetPulseRate(1000000); } @@ -1593,6 +1605,9 @@ fTermColumns = cols; fFrameResized = true; + + if (fScrollBar != NULL) + fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); } From oruizdorantes at mail.berlios.de Fri Feb 8 19:29:33 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 8 Feb 2008 19:29:33 +0100 Subject: [Haiku-commits] r23932 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200802081829.m18ITXmK014067@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-08 19:29:33 +0100 (Fri, 08 Feb 2008) New Revision: 23932 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23932&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h Log: Change macros names, guidelines & consistency Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-02-08 12:16:49 UTC (rev 23931) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-02-08 18:29:33 UTC (rev 23932) @@ -20,9 +20,9 @@ /* Command opcode pack/unpack */ -#define hci_opcode_pack(ogf, ocf) (uint16)((ocf & 0x03ff)|(ogf << 10)) -#define hci_opcode_ogf(op) (op >> 10) -#define hci_opcode_ocf(op) (op & 0x03ff) +#define PACK_OPCODE(ogf, ocf) (uint16)((ocf & 0x03ff)|(ogf << 10)) +#define GET_OPCODE_OGF(op) (op >> 10) +#define GET_OPCODE_OCF(op) (op & 0x03ff) /* - Informational Parameters Command definition - */ From oruizdorantes at mail.berlios.de Fri Feb 8 19:32:52 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 8 Feb 2008 19:32:52 +0100 Subject: [Haiku-commits] r23933 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200802081832.m18IWqE9014279@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-08 19:32:52 +0100 (Fri, 08 Feb 2008) New Revision: 23933 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23933&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h Log: Even code field has more sense like that Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-08 18:29:33 UTC (rev 23932) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-02-08 18:32:52 UTC (rev 23933) @@ -13,7 +13,7 @@ #define HCI_EVENT_HDR_SIZE 2 struct hci_event_header { - uint8 evt; + uint8 ecode; uint8 elen; } __attribute__ ((packed)); From korli at mail.berlios.de Fri Feb 8 22:37:26 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 8 Feb 2008 22:37:26 +0100 Subject: [Haiku-commits] r23934 - haiku/trunk/headers/os/game Message-ID: <200802082137.m18LbQx9002478@sheep.berlios.de> Author: korli Date: 2008-02-08 22:37:25 +0100 (Fri, 08 Feb 2008) New Revision: 23934 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23934&view=rev Modified: haiku/trunk/headers/os/game/SimpleGameSound.h Log: declared entry_ref clean up Modified: haiku/trunk/headers/os/game/SimpleGameSound.h =================================================================== --- haiku/trunk/headers/os/game/SimpleGameSound.h 2008-02-08 18:32:52 UTC (rev 23933) +++ haiku/trunk/headers/os/game/SimpleGameSound.h 2008-02-08 21:37:25 UTC (rev 23934) @@ -1,77 +1,43 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: SimpleGameSound.h -// Author: Christopher ML Zumwalt May (zummy at users.sf.net) -// Description: BSimpleGameSound is a class for sound effects that are -// short, and consists of non-changing samples in memory. -//------------------------------------------------------------------------------ - - +/* + * Copyright 2001-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _SIMPLEGAMESOUND_H #define _SIMPLEGAMESOUND_H -// Standard Includes ----------------------------------------------------------- -// System Includes ------------------------------------------------------------- #include #include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- +struct entry_ref; -// Local Defines --------------------------------------------------------------- -// Globals --------------------------------------------------------------------- - -// BGameSound class ------------------------------------------------------------- -class BSimpleGameSound : public BGameSound -{ +class BSimpleGameSound : public BGameSound { public: - BSimpleGameSound(const entry_ref * inFile, - BGameSoundDevice * device = NULL); - BSimpleGameSound(const char * inFile, - BGameSoundDevice * device = NULL); - BSimpleGameSound(const void * inData, - size_t inFrameCount, - const gs_audio_format * format, - BGameSoundDevice * device = NULL); + BSimpleGameSound(const entry_ref * inFile, + BGameSoundDevice * device = NULL); + BSimpleGameSound(const char * inFile, + BGameSoundDevice * device = NULL); + BSimpleGameSound(const void * inData, + size_t inFrameCount, + const gs_audio_format * format, + BGameSoundDevice * device = NULL); + BSimpleGameSound(const BSimpleGameSound & other); - BSimpleGameSound(const BSimpleGameSound & other); + virtual ~BSimpleGameSound(); - virtual ~BSimpleGameSound(); - virtual BGameSound * Clone() const; - virtual status_t Perform(int32 selector, void * data); + virtual status_t Perform(int32 selector, void * data); - status_t SetIsLooping(bool looping); - bool IsLooping() const; - -private: - status_t Init(const entry_ref * inFile); - status_t Init(const void* inData, - int64 inFrameCount, - const gs_audio_format* format); + status_t SetIsLooping(bool looping); + bool IsLooping() const; + + private: + status_t Init(const entry_ref * inFile); + status_t Init(const void* inData, int64 inFrameCount, + const gs_audio_format* format); /* leave these declarations private unless you plan on actually implementing and using them. */ BSimpleGameSound(); @@ -81,31 +47,32 @@ uint32 _reserved_BSimpleGameSound_[12]; -virtual status_t _Reserved_BSimpleGameSound_0(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_1(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_2(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_3(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_4(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_5(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_6(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_7(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_8(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_9(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_10(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_11(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_12(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_13(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_14(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_15(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_16(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_17(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_18(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_19(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_20(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_21(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_22(int32 arg, ...); -virtual status_t _Reserved_BSimpleGameSound_23(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_0(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_1(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_2(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_3(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_4(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_5(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_6(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_7(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_8(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_9(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_10(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_11(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_12(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_13(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_14(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_15(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_16(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_17(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_18(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_19(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_20(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_21(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_22(int32 arg, ...); + virtual status_t _Reserved_BSimpleGameSound_23(int32 arg, ...); }; #endif // _SIMPLE_GAME_SOUND_H + From jonas at kirilla.com Sat Feb 9 12:26:58 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Sat, 09 Feb 2008 12:26:58 +0100 CET Subject: [Haiku-commits] r23879 - haiku/trunk/src/system/kernel In-Reply-To: <200802052021.m15KLjlI032529@sheep.berlios.de> Message-ID: <2698274990-BeMail@kirilla> mmlr at BerliOS wrote: > Author: mmlr > Date: 2008-02-05 21:21:44 +0100 (Tue, 05 Feb 2008) > New Revision: 23879 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23879&view=rev > > Modified: > haiku/trunk/src/system/kernel/heap.c This made a huge difference. Thank you Michael! /Jonas. From kirilla at mail.berlios.de Sat Feb 9 14:26:29 2008 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Sat, 9 Feb 2008 14:26:29 +0100 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing Message-ID: <200802091326.m19DQTau008612@sheep.berlios.de> Author: kirilla Date: 2008-02-09 14:26:28 +0100 (Sat, 09 Feb 2008) New Revision: 23935 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23935&view=rev Modified: haiku/trunk/src/apps/cdplayer/CDPlayer.cpp haiku/trunk/src/apps/deskcalc/CalcWindow.cpp haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp haiku/trunk/src/apps/tv/config.h haiku/trunk/src/apps/tv/tv.rdef haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp haiku/trunk/src/tests/kits/game/chart/Chart.cpp haiku/trunk/src/tests/servers/app/bitmap_drawing/main.cpp Log: The title of the (primary) window of (non-document) apps and preferences should be the filename of the executable. File and window names should be changed in tandem in the future. All IMO. Sorry, Marcus, for changing TV-O-Rama. :/ We may want to consider using more proper language, e.g. 'Screensaver' or 'Screen Saver' instead of 'ScreenSaver'. DeskCalc or 'Desk Calculator' should be just Calculator. We should avoid clinging to BeOS history, like with the name CodyCam, which hardly makes any sense anymore, even if you happen to be one of the few BeOS oldtimers. Modified: haiku/trunk/src/apps/cdplayer/CDPlayer.cpp =================================================================== --- haiku/trunk/src/apps/cdplayer/CDPlayer.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/cdplayer/CDPlayer.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -600,7 +600,7 @@ CDPlayerWindow::CDPlayerWindow() - : BWindow(BRect (100, 100, 405, 280), "CD Player", B_TITLED_WINDOW, B_NOT_RESIZABLE | + : BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) { } Modified: haiku/trunk/src/apps/deskcalc/CalcWindow.cpp =================================================================== --- haiku/trunk/src/apps/deskcalc/CalcWindow.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/deskcalc/CalcWindow.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -21,7 +21,7 @@ #include "CalcView.h" -static const char* kWindowTitle = "Desk Calculator"; +static const char* kWindowTitle = "DeskCalc"; CalcWindow::CalcWindow(BRect frame) Modified: haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp =================================================================== --- haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -35,7 +35,7 @@ //------------------------------------------------------------------------------ MidiPlayerWindow::MidiPlayerWindow() - : BWindow(BRect(0, 0, 1, 1), "MIDI Player", B_TITLED_WINDOW, + : BWindow(BRect(0, 0, 1, 1), "MidiPlayer", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { playing = false; Modified: haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp =================================================================== --- haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -98,7 +98,7 @@ RecorderWindow::RecorderWindow() : - BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "Sound Recorder", B_TITLED_WINDOW, + BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "SoundRecorder", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE), fPlayer(NULL), fSoundList(NULL), Modified: haiku/trunk/src/apps/tv/config.h =================================================================== --- haiku/trunk/src/apps/tv/config.h 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/tv/config.h 2008-02-09 13:26:28 UTC (rev 23935) @@ -28,7 +28,7 @@ #include #include -#define NAME "TV-O-Rama" +#define NAME "TV" #define REVISION "unknown" #define VERSION "1.1" #define BUILD __DATE__ " "__TIME__ Modified: haiku/trunk/src/apps/tv/tv.rdef =================================================================== --- haiku/trunk/src/apps/tv/tv.rdef 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/apps/tv/tv.rdef 2008-02-09 13:26:28 UTC (rev 23935) @@ -2,7 +2,7 @@ * Icon-O-Matic.rdef */ -resource app_signature "application/x-vnd.MarcusOverhagen.TV-O-Rama"; +resource app_signature "application/x-vnd.MarcusOverhagen.TV"; resource app_version { major = 1, @@ -15,8 +15,8 @@ internal = 0, - short_info = "TV-O-Rama", - long_info = "TV-O-Rama ?2005-2007 Marcus Overhagen" + short_info = "TV", + long_info = "TV ?2005-2007 Marcus Overhagen" }; resource app_flags B_SINGLE_LAUNCH; Modified: haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp =================================================================== --- haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -574,7 +574,7 @@ ScreenSaverWindow::ScreenSaverWindow() - : BWindow(BRect(50, 50, 496, 375), "Screen Saver", + : BWindow(BRect(50, 50, 496, 375), "ScreenSaver", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /*| B_NOT_ZOOMABLE | B_NOT_RESIZABLE*/) { fSettings.Load(); Modified: haiku/trunk/src/tests/kits/game/chart/Chart.cpp =================================================================== --- haiku/trunk/src/tests/kits/game/chart/Chart.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/tests/kits/game/chart/Chart.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -29,7 +29,7 @@ ChartApp::ChartApp() : BApplication("application/x-vnd.Be.ChartDemo") { - fWindow = new ChartWindow(BRect(120, 150, 629, 591), "Charts"); + fWindow = new ChartWindow(BRect(120, 150, 629, 591), "Chart"); // showing the window will also start the direct connection. If you // Sync() after the show, the direct connection will be established Modified: haiku/trunk/src/tests/servers/app/bitmap_drawing/main.cpp =================================================================== --- haiku/trunk/src/tests/servers/app/bitmap_drawing/main.cpp 2008-02-08 21:37:25 UTC (rev 23934) +++ haiku/trunk/src/tests/servers/app/bitmap_drawing/main.cpp 2008-02-09 13:26:28 UTC (rev 23935) @@ -564,7 +564,7 @@ // BRect frame(10.0, 30.0, 790.0, 590.0); BRect frame(10.0, 30.0, 330.0, 220.0); - show_window(frame, "Bitmap Drawing"); + show_window(frame, "BitmapDrawing"); app->Run(); From korli at users.berlios.de Sat Feb 9 17:15:34 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 9 Feb 2008 17:15:34 +0100 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <200802091326.m19DQTau008612@sheep.berlios.de> References: <200802091326.m19DQTau008612@sheep.berlios.de> Message-ID: 2008/2/9, kirilla at BerliOS : DeskCalc or 'Desk Calculator' should be just Calculator. We should avoid clinging to BeOS history, like with the name CodyCam, which hardly makes any sense anymore, even if you happen to be one of the few BeOS oldtimers. Sorry but, for me, these names are ones which mean a non conformist OS. What do you gain in matching the executable name ? Bye, J?r?me From korli at mail.berlios.de Sat Feb 9 18:48:12 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 9 Feb 2008 18:48:12 +0100 Subject: [Haiku-commits] r23936 - in haiku/trunk: build/jam src/add-ons/translators/exr src/add-ons/translators/exr/openexr/half src/add-ons/translators/exr/openexr/ilmimf src/add-ons/translators/exr/openexr/imath Message-ID: <200802091748.m19HmCiE004079@sheep.berlios.de> Author: korli Date: 2008-02-09 18:48:10 +0100 (Sat, 09 Feb 2008) New Revision: 23936 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23936&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp haiku/trunk/src/add-ons/translators/exr/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/half/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/Jamfile haiku/trunk/src/add-ons/translators/exr/openexr/imath/Jamfile Log: have libilmimf built with libstdc++v2 added EXRTranslator to the image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/build/jam/HaikuImage 2008-02-09 17:48:10 UTC (rev 23936) @@ -66,6 +66,7 @@ libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so + libilmimf.so ; BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server net_server media_addon_server input_server app_server fake_app_server @@ -84,7 +85,7 @@ $(X86_ONLY)via.accelerant #$(X86_ONLY)vmware.accelerant ; -BEOS_ADD_ONS_TRANSLATORS = BMPTranslator GIFTranslator JPEGTranslator +BEOS_ADD_ONS_TRANSLATORS = BMPTranslator EXRTranslator GIFTranslator JPEGTranslator JPEG2000Translator TIFFTranslator PNGTranslator PPMTranslator RTF-Translator SGITranslator STXTTranslator TGATranslator WonderBrushTranslator RAWTranslator Modified: haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/src/add-ons/translators/exr/EXRGamma.cpp 2008-02-09 17:48:10 UTC (rev 23936) @@ -8,6 +8,8 @@ #include "ImathFun.h" #include "ImathMath.h" +#include + using namespace std; using Imath::clamp; Modified: haiku/trunk/src/add-ons/translators/exr/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-09 17:48:10 UTC (rev 23936) @@ -20,7 +20,7 @@ TranslatorSettings.cpp TranslatorWindow.cpp - : be translation libilmimf.so + : be translation libilmimf.so $(TARGET_LIBSTDC++) : true ; Modified: haiku/trunk/src/add-ons/translators/exr/openexr/half/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/half/Jamfile 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/src/add-ons/translators/exr/openexr/half/Jamfile 2008-02-09 17:48:10 UTC (rev 23936) @@ -2,6 +2,10 @@ SubDirSysHdrs [ FDirName $(SUBDIR) ] ; +if $(HAIKU_LIBSTDC++) = libstdc++.r4.so { + SubDirC++Flags -Dios_base=ios -ftemplate-depth-24 ; +} + StaticLibrary libhalf.a : eLut.cpp half.cpp Modified: haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/Jamfile 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/src/add-ons/translators/exr/openexr/ilmimf/Jamfile 2008-02-09 17:48:10 UTC (rev 23936) @@ -7,6 +7,10 @@ SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) imath ] ; SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) config ] ; +if $(HAIKU_LIBSTDC++) = libstdc++.r4.so { + SubDirC++Flags -Dios_base=ios -ftemplate-depth-24 ; +} + UseLibraryHeaders zlib ; #StaticLibrary libilmimf.a : Modified: haiku/trunk/src/add-ons/translators/exr/openexr/imath/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/openexr/imath/Jamfile 2008-02-09 13:26:28 UTC (rev 23935) +++ haiku/trunk/src/add-ons/translators/exr/openexr/imath/Jamfile 2008-02-09 17:48:10 UTC (rev 23936) @@ -4,6 +4,10 @@ SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) half ] ; SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) iex ] ; +if $(HAIKU_LIBSTDC++) = libstdc++.r4.so { + SubDirC++Flags -Dios_base=ios -ftemplate-depth-24 ; +} + StaticLibrary libimath.a : ImathBox.cpp ImathColorAlgo.cpp From korli at mail.berlios.de Sat Feb 9 18:55:12 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 9 Feb 2008 18:55:12 +0100 Subject: [Haiku-commits] r23937 - haiku/trunk/src/add-ons/kernel/drivers/input/wacom Message-ID: <200802091755.m19HtChC010798@sheep.berlios.de> Author: korli Date: 2008-02-09 18:55:11 +0100 (Sat, 09 Feb 2008) New Revision: 23937 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23937&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c Log: added missing api_version Modified: haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c 2008-02-09 17:48:10 UTC (rev 23936) +++ haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c 2008-02-09 17:55:11 UTC (rev 23937) @@ -18,6 +18,7 @@ #include #include +int32 api_version = B_CUR_DRIVER_API_VERSION; #define DEBUG_DRIVER 0 From korli at mail.berlios.de Sat Feb 9 19:08:35 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 9 Feb 2008 19:08:35 +0100 Subject: [Haiku-commits] r23938 - haiku/trunk/src/servers/app/drawing Message-ID: <200802091808.m19I8Zhi024102@sheep.berlios.de> Author: korli Date: 2008-02-09 19:08:34 +0100 (Sat, 09 Feb 2008) New Revision: 23938 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23938&view=rev Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp Log: added B_RGBA15 colorspace, and explicitly print which colorspce is unsupported Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-09 17:55:11 UTC (rev 23937) +++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-09 18:08:34 UTC (rev 23938) @@ -657,7 +657,8 @@ } break; } - case B_RGB15: { + case B_RGB15: + case B_RGBA15: { // offset to left top pixel in dest buffer dst += y * dstBPR + x * 2; int32 left = x; @@ -774,7 +775,7 @@ break; default: - fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front buffer format!\n"); + fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front buffer format! (0x%lx)\n", frontBuffer->ColorSpace()); break; } } From jonas at kirilla.com Sun Feb 10 14:45:31 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Sun, 10 Feb 2008 14:45:31 +0100 CET Subject: [Haiku-commits] =?iso-8859-1?q?r23935_-_in_haiku/trunk/src=3A_app?= =?iso-8859-1?q?s/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrecorde?= =?iso-8859-1?q?r_apps/tv_preferences/screensaver_tests/kits/game/chart_te?= =?iso-8859-1?q?sts/servers/app/bitmap=5Fdrawing?= In-Reply-To: Message-ID: <4007811527-BeMail@kirilla> "J?r?me Duval" wrote: > 2008/2/9, kirilla at BerliOS : > DeskCalc or 'Desk Calculator' should be just Calculator. We should > avoid clinging to BeOS history, like with the name CodyCam, which > hardly makes any sense anymore, even if you happen to be one of the > few BeOS oldtimers. > > Sorry but, for me, these names are ones which mean a non conformist > OS. What do you gain in matching the executable name ? Two separate issues here: A. Having an application named "NetPositive" open a window named "Net Positive" is just inconsistent and probably makes the unconscious (and sometimes conscious) mind waste time on a distinction between the two variations which is probably pointless for both creator and user. I suspect mixing the two adds to mental background noise. B. If you try a new OS with applications you've never used before and never heard about, does it help you that they're called e.g. Gulliver, flatfoot, SnakeTP, wiXzzer, GoodMorning? That would be non-conformist, but it would also be aginst common-sense and work against human nature. I know I feel more at ease when the latest Linux distro I try has names and icons that least -hint- the purpose of the apps. I'm -only- talking about the -included- Haiku applications, which are usually limited in scope and which mostly have short, meaningful, self-describing names already. While there may be a very small difference between, say "Icon-O-Matic" and say "IconMaker" I think it may be a good idea, for the user experience as a whole, to try to streamline the names (distilling their essence) so that the full lineup of application names makes sense and reaches the desired level of consistency. CodyCam sticks out simply because there's nothing "Cody" about the application anymore. Few people know who Cody is/was. It just doesn't make sense to perpetuate this name. The gain in clarity by renaming the application (to e.g. WebcamUploader, WebcamPublisher, or whatever) outweighs this small damage to Haiku's BeOS heritage, IMO. This is slightly related to: The Nefarious Baron Owns Your Files!" http://www.beatjapan.org/mirror/www.be.com/users/tips/tip19.html Why expose possibly millions of people to similar old workplace nostalgia? No disregard to the BeOS developers, management, interns, ... but we've go to move on. Honestly. Haiku has room for improvement in soft issues, without going flat-out GlassElevator about things. It's simple things really, like filenames, filetype names, sensible keyboard shortcuts, meaningful icons, good window behaviour. Some amount of consistent behaviour. GUI component reuse. Etc. /Jonas. From revol at free.fr Sun Feb 10 20:18:25 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 10 Feb 2008 20:18:25 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23935_-_in_haiku/trunk/src=3A_a?= =?windows-1252?q?pps/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrec?= =?windows-1252?q?order_apps/tv_preferences/screensaver_tests/kits/game/ch?= =?windows-1252?q?art_tests/servers/app/bitmap=5Fdrawing?= In-Reply-To: Message-ID: <3225060469-BeMail@laptop> > 2008/2/9, kirilla at BerliOS : > DeskCalc or 'Desk Calculator' should be just Calculator. We should > avoid clinging to BeOS history, like with the name CodyCam, which > hardly makes any sense anymore, even if you happen to be one of the > few BeOS oldtimers. > > Sorry but, for me, these names are ones which mean a non conformist > OS. What do you gain in matching the executable name ? plain English names won't mean much more to a non-english speaker anyway... Fran?ois. From jonas at kirilla.com Sun Feb 10 20:54:58 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Sun, 10 Feb 2008 20:54:58 +0100 CET Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <3225060469-BeMail@laptop> Message-ID: <1596145847-BeMail@kirilla> "Fran?ois Revol" wrote: ... > plain English names won't mean much more to a > non-english speaker anyway... I expect Haiku to eventually be translated/localized in its entirety. This is probably what most people expect; to be given the choice between English and ones primary language. It would be rude of us to not try to accomodate them. But that's no reason to be careless with the English prototype. It should constitute best practice and be the authority for localisations to follow. If there is confusion in the prototype, this confusion will multiply. I'd rather not see Haiku in Swedish turn out as bad as Ubuntu in Swedish. /Jonas. From mmlr at mail.berlios.de Sun Feb 10 22:00:15 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 10 Feb 2008 22:00:15 +0100 Subject: [Haiku-commits] r23939 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm Message-ID: <200802102100.m1AL0F71017229@sheep.berlios.de> Author: mmlr Date: 2008-02-10 22:00:13 +0100 (Sun, 10 Feb 2008) New Revision: 23939 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23939&view=rev Added: haiku/trunk/headers/private/kernel/heap.h haiku/trunk/src/system/kernel/heap.cpp Removed: haiku/trunk/headers/private/kernel/memheap.h haiku/trunk/src/system/kernel/heap.c Modified: haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/vm/vm.cpp Log: Complete rework of the heap implementation. Freelists are now part of the pages and pages are now kept in lists as well. This allows to return free pages once a bin does not need them anymore. Partially filled pages are kept in a sorted linked list so that allocation will always happen on the fullest page - this favours having full pages and makes it more likely lightly used pages will get completely empty so they can be returned. Generally this now goes more in the direction of a slab allocator. The allocation logic has been extracted, so a heap is now simply attachable to a region of memory. This allows for multiple heaps and for dynamic growing. In case the allocator runs out of free pages, an asynchronous growing thread is notified to create a new area and attach a new heap to it. By default the kernel heap is now set to 16MB and grows by 8MB each time all heaps run full. This should solve quite a few issues, like certain bins just claiming all pages so that even if there is free space nothing can be allocated. Also it obviously does aways with filling the heap page by page until it overgrows. I think this is now a well performing and scalable allocator we can live with for quite some time. It is well tested under emulation and real hardware and performs as expected. If problems come up there is an extensive sanity checker that can be enabled by PARANOID_VALIDATION that covers most aspects of the allocator. For normal operation this is not necessary though and is therefore disabled by default. Added: haiku/trunk/headers/private/kernel/heap.h =================================================================== --- haiku/trunk/headers/private/kernel/heap.h 2008-02-09 18:08:34 UTC (rev 23938) +++ haiku/trunk/headers/private/kernel/heap.h 2008-02-10 21:00:13 UTC (rev 23939) @@ -0,0 +1,34 @@ +/* + * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ +#ifndef _KERNEL_HEAP_H +#define _KERNEL_HEAP_H + +#include + +// allocate 16MB initial heap for the kernel +#define INITIAL_HEAP_SIZE 16 * 1024 * 1024 +// grow by another 8MB each time the heap runs out of memory +#define HEAP_GROW_SIZE 8 * 1024 * 1024 + + + +#ifdef __cplusplus +extern "C" { +#endif + +void *memalign(size_t alignment, size_t size); + +status_t heap_init(addr_t heapBase, size_t heapSize); +status_t heap_init_post_sem(); +status_t heap_init_post_thread(); + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL_MEMHEAP_H */ Deleted: haiku/trunk/headers/private/kernel/memheap.h Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-02-09 18:08:34 UTC (rev 23938) +++ haiku/trunk/src/system/kernel/Jamfile 2008-02-10 21:00:13 UTC (rev 23939) @@ -21,7 +21,7 @@ condition_variable.cpp cpu.c elf.cpp - heap.c + heap.cpp image.c int.c kernel_daemon.c Deleted: haiku/trunk/src/system/kernel/heap.c Added: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-09 18:08:34 UTC (rev 23938) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-10 21:00:13 UTC (rev 23939) @@ -0,0 +1,921 @@ +/* + * Copyright 2008, Michael Lotz, mmlr at mlotz.ch. + * Distributed under the terms of the MIT License. + * + * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#define TRACE_HEAP +#ifdef TRACE_HEAP +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +// initialize newly allocated memory with something non zero +#define PARANOID_KMALLOC 1 +// check for double free, and fill freed memory with 0xdeadbeef +#define PARANOID_KFREE 1 +// validate sanity of the heap after each operation (slow!) +#define PARANOID_VALIDATION 0 + +typedef struct heap_page_s { + uint16 index; + uint16 bin_index : 5; + uint16 free_count : 10; + uint16 in_use : 1; + heap_page_s * next; + heap_page_s * prev; + uint16 empty_index; + addr_t * free_list; +} heap_page; + +// used for bin == bin_count allocations +#define allocation_id free_count + +typedef struct heap_bin_s { + uint32 element_size; + uint16 max_free_count; + heap_page * page_list; // sorted so that the desired page is always first +} heap_bin; + +typedef struct heap_allocator_s { + addr_t base; + size_t size; + mutex lock; + vint32 large_alloc_id; + + uint32 bin_count; + uint32 page_count; + heap_page * free_pages; + + heap_bin * bins; + heap_page * page_table; + + heap_allocator_s * next; +} heap_allocator; + +static heap_allocator *sHeapList = NULL; +static heap_allocator *sLastGrowRequest = NULL; +static sem_id sHeapGrowSem = -1; +static sem_id sHeapGrownNotify = -1; + + +static void +dump_page(heap_page *page) +{ + uint32 count = 0; + for (addr_t *temp = page->free_list; temp != NULL; temp = (addr_t *)*temp) + count++; + + dprintf("\t\tpage %p: bin_index: %u; free_count: %u; empty_index: %u; free_list %p (%lu entr%s)\n", + page, page->bin_index, page->free_count, page->empty_index, + page->free_list, count, count == 1 ? "y" : "ies"); +} + + +static void +dump_bin(heap_bin *bin) +{ + dprintf("\telement_size: %lu; max_free_count: %u; page_list %p;\n", + bin->element_size, bin->max_free_count, bin->page_list); + + for (heap_page *temp = bin->page_list; temp != NULL; temp = temp->next) + dump_page(temp); +} + + +static void +dump_allocator(heap_allocator *heap) +{ + uint32 count = 0; + for (heap_page *page = heap->free_pages; page != NULL; page = page->next) + count++; + + dprintf("allocator %p: base: 0x%08lx; size: %lu; bin_count: %lu; free_pages: %p (%lu entr%s)\n", heap, + heap->base, heap->size, heap->bin_count, heap->free_pages, count, + count == 1 ? "y" : "ies"); + + for (uint32 i = 0; i < heap->bin_count; i++) + dump_bin(&heap->bins[i]); + + dprintf("\n"); +} + + +static int +dump_heap_list(int argc, char **argv) +{ + heap_allocator *heap = sHeapList; + while (heap) { + dump_allocator(heap); + heap = heap->next; + } + + return 0; +} + + +#if PARANOID_VALIDATION +static void +heap_validate_heap(heap_allocator *heap) +{ + mutex_lock(&heap->lock); + + // validate the free pages list + uint32 freePageCount = 0; + heap_page *lastPage = NULL; + heap_page *page = heap->free_pages; + while (page) { + if ((addr_t)page < (addr_t)&heap->page_table[0] + || (addr_t)page >= (addr_t)&heap->page_table[heap->page_count]) + panic("free page is not part of the page table\n"); + + if (page->index >= heap->page_count) + panic("free page has invalid index\n"); + + if ((addr_t)&heap->page_table[page->index] != (addr_t)page) + panic("free page index does not lead to target page\n"); + + if (page->prev != lastPage) + panic("free page entry has invalid prev link\n"); + + if (page->in_use) + panic("free page marked as in use\n"); + + lastPage = page; + page = page->next; + freePageCount++; + } + + // validate the page table + uint32 usedPageCount = 0; + for (uint32 i = 0; i < heap->page_count; i++) { + if (heap->page_table[i].in_use) + usedPageCount++; + } + + if (freePageCount + usedPageCount != heap->page_count) { + panic("free pages and used pages do not add up (%lu + %lu != %lu)\n", + freePageCount, usedPageCount, heap->page_count); + } + + // validate the bins + for (uint32 i = 0; i < heap->bin_count; i++) { + heap_bin *bin = &heap->bins[i]; + + lastPage = NULL; + page = bin->page_list; + int32 lastFreeCount = 0; + while (page) { + if ((addr_t)page < (addr_t)&heap->page_table[0] + || (addr_t)page >= (addr_t)&heap->page_table[heap->page_count]) + panic("used page is not part of the page table\n"); + + if (page->index >= heap->page_count) + panic("used page has invalid index\n"); + + if ((addr_t)&heap->page_table[page->index] != (addr_t)page) + panic("used page index does not lead to target page\n"); + + if (page->prev != lastPage) + panic("used page entry has invalid prev link (%p vs %p bin %lu)\n", + page->prev, lastPage, i); + + if (!page->in_use) + panic("used page marked as not in use\n"); + + if (page->bin_index != i) + panic("used page with bin index %u in page list of bin %lu\n", + page->bin_index, i); + + if (page->free_count < lastFreeCount) + panic("ordering of bin page list broken\n"); + + // validate the free list + uint32 freeSlotsCount = 0; + addr_t *element = page->free_list; + addr_t pageBase = heap->base + page->index * B_PAGE_SIZE; + while (element) { + if ((addr_t)element < pageBase + || (addr_t)element >= pageBase + B_PAGE_SIZE) + panic("free list entry out of page range\n"); + + if (((addr_t)element - pageBase) % bin->element_size != 0) + panic("free list entry not on a element boundary\n"); + + element = (addr_t *)*element; + freeSlotsCount++; + } + + uint32 slotCount = bin->max_free_count; + if (page->empty_index > slotCount) + panic("empty index beyond slot count (%u with %lu slots)\n", + page->empty_index, slotCount); + + freeSlotsCount += (slotCount - page->empty_index); + if (freeSlotsCount > slotCount) + panic("more free slots than fit into the page\n"); + + lastPage = page; + lastFreeCount = page->free_count; + page = page->next; + } + } + + mutex_unlock(&heap->lock); +} +#endif + + +heap_allocator * +heap_attach(addr_t base, size_t size, bool postSem) +{ + heap_allocator *heap = (heap_allocator *)base; + base += sizeof(heap_allocator); + size -= sizeof(heap_allocator); + + size_t binSizes[] = { 16, 32, 64, 96, 128, 192, 256, 384, 512, 1024, 2048, B_PAGE_SIZE }; + uint32 binCount = sizeof(binSizes) / sizeof(binSizes[0]); + heap->bin_count = binCount; + heap->bins = (heap_bin *)base; + base += binCount * sizeof(heap_bin); + size -= binCount * sizeof(heap_bin); + + for (uint32 i = 0; i < binCount; i++) { + heap_bin *bin = &heap->bins[i]; + bin->element_size = binSizes[i]; + bin->max_free_count = B_PAGE_SIZE / binSizes[i]; + bin->page_list = NULL; + } + + uint32 pageCount = size / B_PAGE_SIZE; + size_t pageTableSize = pageCount * sizeof(heap_page); + heap->page_table = (heap_page *)base; + base += pageTableSize; + size -= pageTableSize; + + // the rest is now actually usable memory (rounded to the next page) + heap->base = (addr_t)(base + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE; + heap->size = (size_t)(size / B_PAGE_SIZE) * B_PAGE_SIZE; + + // now we know the real page count + pageCount = heap->size / B_PAGE_SIZE; + heap->page_count = pageCount; + + // zero out the heap alloc table at the base of the heap + memset((void *)heap->page_table, 0, pageTableSize); + for (uint32 i = 0; i < pageCount; i++) + heap->page_table[i].index = i; + + // add all pages up into the free pages list + for (uint32 i = 1; i < pageCount; i++) { + heap->page_table[i - 1].next = &heap->page_table[i]; + heap->page_table[i].prev = &heap->page_table[i - 1]; + } + heap->free_pages = &heap->page_table[0]; + heap->page_table[0].prev = NULL; + + if (postSem) { + if (mutex_init(&heap->lock, "heap_mutex") < 0) { + panic("heap_attach(): error creating heap mutex\n"); + return NULL; + } + } else { + // pre-init the mutex to at least fall through any semaphore calls + heap->lock.sem = -1; + heap->lock.holder = -1; + } + + heap->next = NULL; + dprintf("heap_attach: attached to %p - usable range 0x%08lx - 0x%08lx\n", + heap, heap->base, heap->base + heap->size); + return heap; +} + + +static inline uint32 +heap_next_alloc_id(heap_allocator *heap) +{ + return atomic_add(&heap->large_alloc_id, 1) & ((1 << 9) - 1); +} + + +static inline void +heap_link_page(heap_page *page, heap_page **list) +{ + page->prev = NULL; + page->next = *list; + if (page->next) + page->next->prev = page; + *list = page; +} + + +static inline void +heap_unlink_page(heap_page *page, heap_page **list) +{ + if (page->prev) + page->prev->next = page->next; + if (page->next) + page->next->prev = page->prev; + if (list && *list == page) { + *list = page->next; + if (page->next) + page->next->prev = NULL; + } +} + + +static void * +heap_raw_alloc(heap_allocator *heap, size_t size, uint32 binIndex) +{ + heap_bin *bin = NULL; + if (binIndex < heap->bin_count) + bin = &heap->bins[binIndex]; + + if (bin && bin->page_list != NULL) { + // we have a page where we have a free slot + void *address = NULL; + heap_page *page = bin->page_list; + if (page->free_list) { + // there's a previously freed entry we can use + address = page->free_list; + page->free_list = (addr_t *)*page->free_list; + } else { + // the page hasn't been fully allocated so use the next empty_index + address = (void *)(heap->base + page->index * B_PAGE_SIZE + + page->empty_index * bin->element_size); + page->empty_index++; + } + + page->free_count--; + if (page->free_count == 0) { + // the page is now full so we remove it from the page_list + bin->page_list = page->next; + if (page->next) + page->next->prev = NULL; + page->next = page->prev = NULL; + } + + return address; + } + + // we don't have anything free right away, we must allocate a new page + if (heap->free_pages == NULL) { + // there are no free pages anymore, we ran out of memory + TRACE(("heap %p: no free pages to allocate %lu bytes\n", heap, size)); + return NULL; + } + + if (bin) { + // small allocation, just grab the next free page + heap_page *page = heap->free_pages; + heap->free_pages = page->next; + if (page->next) + page->next->prev = NULL; + + page->in_use = 1; + page->bin_index = binIndex; + page->free_count = bin->max_free_count - 1; + page->empty_index = 1; + page->free_list = NULL; + page->next = page->prev = NULL; + + if (page->free_count > 0) { + // by design there are no other pages in the bins page list + bin->page_list = page; + } + + // we return the first slot in this page + return (void *)(heap->base + page->index * B_PAGE_SIZE); + } + + // large allocation, we must search for contiguous slots + bool found = false; + int32 first = -1; + for (uint32 i = 0; i < heap->page_count; i++) { + if (heap->page_table[i].in_use) { + first = -1; + continue; + } + + if (first > 0) { + if ((1 + i - first) * B_PAGE_SIZE >= size) { + found = true; + break; + } + } else + first = i; + } + + if (!found) { + TRACE(("heap %p: found no contiguous pages to allocate %ld bytes\n", heap, size)); + return NULL; + } + + uint32 allocationID = heap_next_alloc_id(heap); + uint32 pageCount = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE; + for (uint32 i = first; i < first + pageCount; i++) { + heap_page *page = &heap->page_table[i]; + page->in_use = 1; + page->bin_index = binIndex; + + heap_unlink_page(page, &heap->free_pages); + + page->next = page->prev = NULL; + page->free_list = NULL; + page->allocation_id = allocationID; + } + + return (void *)(heap->base + first * B_PAGE_SIZE); +} + + +#if DEBUG +static bool +is_valid_alignment(size_t number) +{ + // this cryptic line accepts zero and all powers of two + return ((~number + 1) | ((number << 1) - 1)) == ~0UL; +} +#endif + + +static void * +heap_memalign(heap_allocator *heap, size_t alignment, size_t size, + bool *shouldGrow) +{ + TRACE(("memalign(alignment = %lu, size = %lu)\n", alignment, size)); + +#if DEBUG + if (!is_valid_alignment(alignment)) + panic("memalign() with an alignment which is not a power of 2\n"); +#endif + + mutex_lock(&heap->lock); + + // ToDo: that code "aligns" the buffer because the bins are always + // aligned on their bin size + if (size < alignment) + size = alignment; + + uint32 binIndex; + for (binIndex = 0; binIndex < heap->bin_count; binIndex++) { + if (size <= heap->bins[binIndex].element_size) + break; + } + + void *address = heap_raw_alloc(heap, size, binIndex); + + TRACE(("memalign(): asked to allocate %lu bytes, returning pointer %p\n", size, address)); + + if (heap->next == NULL) { + // suggest growing if we are the last heap and we have + // less than three free pages left + *shouldGrow = (heap->free_pages == NULL + || heap->free_pages->next == NULL + || heap->free_pages->next->next == NULL); + } + + mutex_unlock(&heap->lock); + if (address == NULL) + return address; + +#if PARANOID_KFREE + // make sure 0xdeadbeef is cleared if we do not overwrite the memory + // and the user does not clear it + ((uint32 *)address)[1] = 0xcccccccc; +#endif + +#if PARANOID_KMALLOC + memset(address, 0xcc, size); +#endif + + return address; +} + + +static status_t +heap_free(heap_allocator *heap, void *address) +{ + if (address == NULL) + return B_OK; + + if ((addr_t)address < heap->base + || (addr_t)address >= heap->base + heap->size) { + // this address does not belong to us + return B_ENTRY_NOT_FOUND; + } + + mutex_lock(&heap->lock); + + TRACE(("free(): asked to free at ptr = %p\n", address)); + + heap_page *page = &heap->page_table[((addr_t)address - heap->base) / B_PAGE_SIZE]; + + TRACE(("free(): page %p: bin_index %d, free_count %d\n", page, page->bin_index, page->free_count)); + + if (page->bin_index > heap->bin_count) { + panic("free(): page %p: invalid bin_index %d\n", page, page->bin_index); + mutex_unlock(&heap->lock); + return B_ERROR; + } + + if (page->bin_index < heap->bin_count) { + // small allocation + heap_bin *bin = &heap->bins[page->bin_index]; + if (((addr_t)address - heap->base - page->index * B_PAGE_SIZE) % bin->element_size != 0) { + panic("free(): passed invalid pointer %p supposed to be in bin for element size %ld\n", address, bin->element_size); + mutex_unlock(&heap->lock); + return B_ERROR; + } + +#if PARANOID_KFREE + if (((uint32 *)address)[1] == 0xdeadbeef) { + // This block looks like it was freed already, walk the free list + // on this page to make sure this address doesn't exist. + for (addr_t *temp = page->free_list; temp != NULL; temp = (addr_t *)*temp) { + if (temp == address) { + panic("free(): address %p already exists in page free list\n", address); + mutex_unlock(&heap->lock); + return B_ERROR; + } + } + } + + uint32 *dead = (uint32 *)address; + if (bin->element_size % 4 != 0) { + panic("free(): didn't expect a bin element size that is not a multiple of 4\n"); + mutex_unlock(&heap->lock); + return B_ERROR; + } + + // the first 4 bytes are overwritten with the next free list pointer later + for (uint32 i = 1; i < bin->element_size / sizeof(uint32); i++) + dead[i] = 0xdeadbeef; +#endif + + // add the address to the page free list + *(addr_t *)address = (addr_t)page->free_list; + page->free_list = (addr_t *)address; + page->free_count++; + + if (page->free_count == bin->max_free_count) { + // we are now empty, remove the page from the bin list + heap_unlink_page(page, &bin->page_list); + page->in_use = 0; + heap_link_page(page, &heap->free_pages); + } else if (page->free_count == 1) { + // we need to add ourselfs to the page list of the bin + heap_link_page(page, &bin->page_list); + } else { + // we might need to move back in the free pages list + if (page->next && page->next->free_count < page->free_count) { + // move ourselfs so the list stays ordered + heap_page *insert = page->next; + while (insert->next + && insert->next->free_count < page->free_count) + insert = insert->next; + + heap_unlink_page(page, &bin->page_list); + + page->prev = insert; + page->next = insert->next; + if (page->next) + page->next->prev = page; + insert->next = page; + } + } + } else { + // large allocation, just return the pages to the page free list + uint32 allocationID = page->allocation_id; + uint32 maxPages = heap->page_count - page->index; + for (uint32 i = 0; i < maxPages; i++) { + // loop until we find the end of this allocation + if (!page[i].in_use || page[i].bin_index != heap->bin_count + || page[i].allocation_id != allocationID) + break; + + // this page still belongs to the same allocation + page[i].in_use = 0; + page[i].allocation_id = 0; + + // return it to the free list + heap_link_page(&page[i], &heap->free_pages); + } + } + + mutex_unlock(&heap->lock); + return B_OK; +} + + +static status_t +heap_realloc(heap_allocator *heap, void *address, void **newAddress, + size_t newSize) +{ + if ((addr_t)address < heap->base + || (addr_t)address >= heap->base + heap->size) { + // this address does not belong to us + return B_ENTRY_NOT_FOUND; + } + + mutex_lock(&heap->lock); + TRACE(("realloc(address = %p, newSize = %lu)\n", address, newSize)); + + heap_page *page = &heap->page_table[((addr_t)address - heap->base) / B_PAGE_SIZE]; + if (page->bin_index > heap->bin_count) { + panic("realloc(): page %p: invalid bin_index %d\n", page, page->bin_index); + mutex_unlock(&heap->lock); + return B_ERROR; + } + + // find out the size of the old allocation first + size_t minSize = 0; + size_t maxSize = 0; + if (page->bin_index < heap->bin_count) { + // this was a small allocation + heap_bin *bin = &heap->bins[page->bin_index]; + maxSize = bin->element_size; + if (page->bin_index > 0) + minSize = heap->bins[page->bin_index - 1].element_size + 1; + } else { + // this was a large allocation + uint32 allocationID = page->allocation_id; + uint32 maxPages = heap->page_count - page->index; + maxSize = B_PAGE_SIZE; + for (uint32 i = 1; i < maxPages; i++) { + if (!page[i].in_use || page[i].bin_index != heap->bin_count + || page[i].allocation_id != allocationID) + break; + + minSize += B_PAGE_SIZE; + maxSize += B_PAGE_SIZE; + } + } + + mutex_unlock(&heap->lock); + + // does the new allocation simply fit in the old allocation? + if (newSize > minSize && newSize <= maxSize) { + *newAddress = address; + return B_OK; + } + + // if not, allocate a new chunk of memory + *newAddress = malloc(newSize); + if (*newAddress == NULL) { + // we tried but it didn't work out, but still the operation is done + return B_OK; + } + + // copy the old data and free the old allocation + memcpy(*newAddress, address, min_c(maxSize, newSize)); + free(address); + return B_OK; +} + + +// #pragma mark - + + +static int32 +heap_grow_thread(void *) +{ + heap_allocator *heap = sHeapList; + while (true) { + // wait for a request to grow the heap list + if (acquire_sem(sHeapGrowSem) < B_OK) + continue; + + // find the last heap + while (heap->next) + heap = heap->next; + + if (sLastGrowRequest != heap) { + // we have already grown since the latest request, just ignore + continue; + } + + TRACE(("heap_grower: kernel heap will run out of memory soon, allocating new one\n")); + void *heapAddress = NULL; + area_id heapArea = create_area("additional heap", &heapAddress, + B_ANY_KERNEL_BLOCK_ADDRESS, HEAP_GROW_SIZE, B_FULL_LOCK, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + if (heapArea < B_OK) { + panic("heap_grower: couldn't allocate additional heap area\n"); + continue; + } + + heap_allocator *newHeap = heap_attach((addr_t)heapAddress, + HEAP_GROW_SIZE, true); + if (newHeap == NULL) { + panic("heap_grower: could not attach additional heap!\n"); + delete_area(heapArea); + continue; + } + +#if PARANOID_VALIDATION + heap_validate_heap(newHeap); +#endif + heap->next = newHeap; + TRACE(("heap_grower: new heap linked in\n")); + + // notify anyone waiting for this request + release_sem_etc(sHeapGrownNotify, -1, B_RELEASE_ALL); + } + + return 0; +} + + +status_t +heap_init(addr_t base, size_t size) +{ + sHeapList = heap_attach(base, size, false); + + // set up some debug commands + add_debugger_command("heap", &dump_heap_list, "dump stats about the kernel heap(s)"); + return B_OK; +} + + +status_t +heap_init_post_sem() +{ + // create the lock for the initial heap + if (mutex_init(&sHeapList->lock, "heap_mutex") < B_OK) { + panic("heap_init_post_sem(): error creating heap mutex\n"); + return B_ERROR; + } + + sHeapGrowSem = create_sem(0, "heap_grow_sem"); + if (sHeapGrowSem < 0) { + panic("heap_init_post_sem(): failed to create heap grow sem\n"); + return B_ERROR; + } + + sHeapGrownNotify = create_sem(0, "heap_grown_notify"); + if (sHeapGrownNotify < 0) { + panic("heap_init_post_sem(): failed to create heap grown notify sem\n"); + return B_ERROR; + } + + return B_OK; +} + + +status_t +heap_init_post_thread() +{ + thread_id thread = spawn_kernel_thread(heap_grow_thread, "heap grower", + B_URGENT_PRIORITY, NULL); + if (thread < 0) { + panic("heap_init_post_thread(): cannot create heap grow thread\n"); + return B_ERROR; + } + + send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); + return B_OK; +} + + +// #pragma mark - + + +void * +memalign(size_t alignment, size_t size) +{ + if (!kernel_startup && !are_interrupts_enabled()) { + panic("memalign(): called with interrupts disabled\n"); + return NULL; + } + + if (size > (HEAP_GROW_SIZE * 3) / 4) { + // don't even attempt such a huge allocation + panic("heap: huge allocation of %lu bytes asked!\n", size); + return NULL; + } + + heap_allocator *heap = sHeapList; + while (heap) { + bool shouldGrow = false; + void *result = heap_memalign(heap, alignment, size, &shouldGrow); + if (heap->next == NULL && (shouldGrow || result == NULL)) { + // the last heap will or has run out of memory, notify the grower + sLastGrowRequest = heap; + if (result == NULL) { + // urgent request, do the request and wait for at max 250ms + release_sem(sHeapGrowSem); + acquire_sem_etc(sHeapGrownNotify, 1, B_RELATIVE_TIMEOUT, 250000); + } else { + // not so urgent, just notify the grower + release_sem_etc(sHeapGrowSem, 1, B_DO_NOT_RESCHEDULE); + } + } + + if (result == NULL) { + heap = heap->next; + continue; + } + +#if PARANOID_VALIDATION + heap_validate_heap(heap); +#endif + + return result; + } + + panic("heap: kernel heap has run out of memory\n"); + return NULL; +} + + +void * +malloc(size_t size) +{ + return memalign(0, size); +} + + +void +free(void *address) +{ + if (!kernel_startup && !are_interrupts_enabled()) { + panic("free(): called with interrupts disabled\n"); + return; + } + + heap_allocator *heap = sHeapList; + while (heap) { + if (heap_free(heap, address) == B_OK) { +#if PARANOID_VALIDATION + heap_validate_heap(heap); +#endif + return; + } + + heap = heap->next; + } + + panic("free(): free failed for address %p\n", address); +} + + +void * +realloc(void *address, size_t newSize) +{ + if (!kernel_startup && !are_interrupts_enabled()) { + panic("realloc(): called with interrupts disabled\n"); + return NULL; + } + + if (address == NULL) + return malloc(newSize); + + if (newSize == 0) { + free(address); + return NULL; + } + + heap_allocator *heap = sHeapList; + while (heap) { + void *newAddress = NULL; + if (heap_realloc(heap, address, &newAddress, newSize) == B_OK) { +#if PARANOID_VALIDATION + heap_validate_heap(heap); +#endif + return newAddress; + } + + heap = heap->next; + } + + panic("realloc(): failed to realloc address %p to size %lu\n", address, newSize); + return NULL; +} + + +void * +calloc(size_t numElements, size_t size) +{ + void *address = memalign(0, numElements * size); + if (address != NULL) + memset(address, 0, numElements * size); + + return address; +} Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-02-09 18:08:34 UTC (rev 23938) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-02-10 21:00:13 UTC (rev 23939) @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -3480,16 +3480,8 @@ vm_page_init_num_pages(args); [... truncated: 37 lines follow ...] From korli at mail.berlios.de Sun Feb 10 22:03:35 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 10 Feb 2008 22:03:35 +0100 Subject: [Haiku-commits] r23940 - haiku/trunk/src/kits/midi Message-ID: <200802102103.m1AL3Z0m017686@sheep.berlios.de> Author: korli Date: 2008-02-10 22:03:34 +0100 (Sun, 10 Feb 2008) New Revision: 23940 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23940&view=rev Modified: haiku/trunk/src/kits/midi/MidiStore.cpp Log: fixed looping mode, and bug #1730 Modified: haiku/trunk/src/kits/midi/MidiStore.cpp =================================================================== --- haiku/trunk/src/kits/midi/MidiStore.cpp 2008-02-10 21:00:13 UTC (rev 23939) +++ haiku/trunk/src/kits/midi/MidiStore.cpp 2008-02-10 21:03:34 UTC (rev 23940) @@ -426,8 +426,9 @@ if (fLooping) { resetTime = true; fCurrentEvent = 0; - } else - break; + continue; + } + break; } if (firstEvent) { From mmu_man at mail.berlios.de Sun Feb 10 22:52:05 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 10 Feb 2008 22:52:05 +0100 Subject: [Haiku-commits] r23941 - haiku/trunk/src/apps/fontdemo Message-ID: <200802102152.m1ALq5cM021629@sheep.berlios.de> Author: mmu_man Date: 2008-02-10 22:52:05 +0100 (Sun, 10 Feb 2008) New Revision: 23941 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23941&view=rev Modified: haiku/trunk/src/apps/fontdemo/FontDemoView.cpp Log: Fix freeing uninitialized pointer. Modified: haiku/trunk/src/apps/fontdemo/FontDemoView.cpp =================================================================== --- haiku/trunk/src/apps/fontdemo/FontDemoView.cpp 2008-02-10 21:03:34 UTC (rev 23940) +++ haiku/trunk/src/apps/fontdemo/FontDemoView.cpp 2008-02-10 21:52:05 UTC (rev 23941) @@ -29,7 +29,8 @@ fOutLineLevel(0), fDrawingMode(B_OP_COPY), fBoundingBoxes(false), - fDrawShapes(false) + fDrawShapes(false), + fShapes(NULL) { SetViewColor(B_TRANSPARENT_COLOR); SetString("Haiku, inc."); From mmlr at mail.berlios.de Sun Feb 10 22:53:53 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 10 Feb 2008 22:53:53 +0100 Subject: [Haiku-commits] r23942 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802102153.m1ALrrxC021747@sheep.berlios.de> Author: mmlr Date: 2008-02-10 22:53:53 +0100 (Sun, 10 Feb 2008) New Revision: 23942 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23942&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp Log: Fix the build. Apparently this file wasn't recompiled on my end before. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-02-10 21:52:05 UTC (rev 23941) +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-02-10 21:53:53 UTC (rev 23942) @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include From mmu_man at mail.berlios.de Sun Feb 10 23:29:42 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 10 Feb 2008 23:29:42 +0100 Subject: [Haiku-commits] r23943 - haiku/trunk/src/apps/resedit Message-ID: <200802102229.m1AMTgcL028756@sheep.berlios.de> Author: mmu_man Date: 2008-02-10 23:29:42 +0100 (Sun, 10 Feb 2008) New Revision: 23943 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23943&view=rev Modified: haiku/trunk/src/apps/resedit/App.cpp haiku/trunk/src/apps/resedit/App.h Log: Handle command line args. It still opens an empty window though. Modified: haiku/trunk/src/apps/resedit/App.cpp =================================================================== --- haiku/trunk/src/apps/resedit/App.cpp 2008-02-10 21:53:53 UTC (rev 23942) +++ haiku/trunk/src/apps/resedit/App.cpp 2008-02-10 22:29:42 UTC (rev 23943) @@ -80,6 +80,20 @@ void +App::ArgvReceived(int32 argc, char** argv) +{ + int i; + for (i = 1; i < argc; i++) { + BEntry entry(argv[i]); + entry_ref ref; + if (entry.GetRef(&ref) < B_OK) + continue; + ResWindow *win = new ResWindow(BRect(50,100,600,400),&ref); + win->Show(); + } +} + +void App::RefsReceived(BMessage *msg) { entry_ref ref; Modified: haiku/trunk/src/apps/resedit/App.h =================================================================== --- haiku/trunk/src/apps/resedit/App.h 2008-02-10 21:53:53 UTC (rev 23942) +++ haiku/trunk/src/apps/resedit/App.h 2008-02-10 22:29:42 UTC (rev 23943) @@ -24,6 +24,7 @@ App(void); ~App(void); void MessageReceived(BMessage *msg); + void ArgvReceived(int32 argc, char** argv); void RefsReceived(BMessage *msg); void ReadyToRun(void); bool QuitRequested(void); From marcusoverhagen at mail.berlios.de Mon Feb 11 00:39:37 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 11 Feb 2008 00:39:37 +0100 Subject: [Haiku-commits] r23944 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200802102339.m1ANdbOU023331@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-11 00:39:35 +0100 (Mon, 11 Feb 2008) New Revision: 23944 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23944&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp Log: Rewrote mapping of domains and busses into a virtual bus number to allow arbitrary bus numbers. Disabled domain support for __INTEL__. This should fix bug #1774 Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-02-10 22:29:42 UTC (rev 23943) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-02-10 23:39:35 UTC (rev 23944) @@ -41,13 +41,13 @@ uint32 -pci_read_config(uint8 virt_bus, uint8 device, uint8 function, uint8 offset, uint8 size) +pci_read_config(uint8 virtualBus, uint8 device, uint8 function, uint8 offset, uint8 size) { uint8 bus; int domain; uint32 value; - if (sPCI->GetVirtBus(virt_bus, &domain, &bus) != B_OK) + if (sPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK) return 0xffffffff; if (sPCI->ReadPciConfig(domain, bus, device, function, offset, size, &value) != B_OK) @@ -58,12 +58,12 @@ void -pci_write_config(uint8 virt_bus, uint8 device, uint8 function, uint8 offset, uint8 size, uint32 value) +pci_write_config(uint8 virtualBus, uint8 device, uint8 function, uint8 offset, uint8 size, uint32 value) { uint8 bus; int domain; - if (sPCI->GetVirtBus(virt_bus, &domain, &bus) != B_OK) + if (sPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK) return; sPCI->WritePciConfig(domain, bus, device, function, offset, size, value); @@ -313,6 +313,8 @@ : fRootBus(0) , fDomainCount(0) , fBusEnumeration(false) + , fVirtualBusMap() + , fNextVirtualBus(0) { #if defined(__POWERPC__) || defined(__M68K__) fBusEnumeration = true; @@ -360,31 +362,72 @@ status_t -PCI::AddVirtBus(int domain, uint8 bus, uint8 *virt_bus) +PCI::CreateVirtualBus(int domain, uint8 bus, uint8 *virtualBus) { - if (MAX_PCI_DOMAINS != 8) - panic("PCI::AddVirtBus only 8 controllers supported"); - - if (domain > 7) - panic("PCI::AddVirtBus domain %d too large", domain); +#if defined(__INTEL__) - if (bus > 31) - panic("PCI::AddVirtBus bus %d too large", bus); - - *virt_bus = (domain << 5) | bus; + // IA32 doesn't use domains + if (domain) + panic("PCI::CreateVirtualBus domain != 0"); + *virtualBus = bus; return B_OK; + +#else + + if (fNextVirtualBus > 0xff) + panic("PCI::CreateVirtualBus: virtual bus number space exhausted"); + if (unsigned(domain) > 0xff) + panic("PCI::CreateVirtualBus: domain %d too large", domain); + + uint16 value = domain << 8 | bus; + + // XXX iterate through entries 0 to fNextVirtualBus + // XXX and check if value is already present, return + // XXX key if found instead of inserting a new one + + *virtualBus = fNextVirtualBus++; + + dprintf("CreateVirtualBus domain %d, bus %d => virtualBus %d\n", domain, bus, *virtualBus); + + return fVirtualBusMap.Insert(*virtualBus, value); + +#endif } status_t -PCI::GetVirtBus(uint8 virt_bus, int *domain, uint8 *bus) +PCI::ResolveVirtualBus(uint8 virtualBus, int *domain, uint8 *bus) { - // XXX if you modify this, also change pci_info.cpp print_info_basic() !! - *domain = virt_bus >> 5; - *bus = virt_bus & 0x1f; +#if defined(__INTEL__) + + // IA32 doesn't use domains + *bus = virtualBus; + *domain = 0; return B_OK; + +#else + + if (virtualBus >= fNextVirtualBus) + return B_ERROR; + + uint16 value = fVirtualBusMap.Get(virtualBus); + *domain = value >> 8; + *bus = value & 0xff; + return B_OK; + +#endif } + +// used by pci_info.cpp print_info_basic() +void +__pci_resolve_virtual_bus(uint8 virtualBus, int *domain, uint8 *bus) +{ + if (sPCI->ResolveVirtualBus(virtualBus, domain, bus) < B_OK) + panic("ResolveVirtualBus failed"); +} + + status_t PCI::AddController(pci_controller *controller, void *controller_cookie) { @@ -745,16 +788,16 @@ void PCI::ReadPciBasicInfo(PCIDev *dev) { - uint8 virt_bus; + uint8 virtualBus; - if (AddVirtBus(dev->domain, dev->bus, &virt_bus) != B_OK) { - dprintf("PCI: AddVirtBus failed, domain %u, bus %u\n", dev->domain, dev->bus); + if (CreateVirtualBus(dev->domain, dev->bus, &virtualBus) != B_OK) { + dprintf("PCI: CreateVirtualBus failed, domain %u, bus %u\n", dev->domain, dev->bus); return; } dev->info.vendor_id = ReadPciConfig(dev->domain, dev->bus, dev->dev, dev->func, PCI_vendor_id, 2); dev->info.device_id = ReadPciConfig(dev->domain, dev->bus, dev->dev, dev->func, PCI_device_id, 2); - dev->info.bus = virt_bus; + dev->info.bus = virtualBus; dev->info.device = dev->dev; dev->info.function = dev->func; dev->info.revision = ReadPciConfig(dev->domain, dev->bus, dev->dev, dev->func, PCI_revision, 1); Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-02-10 22:29:42 UTC (rev 23943) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-02-10 23:39:35 UTC (rev 23944) @@ -10,6 +10,10 @@ #include +#ifdef __cplusplus + #include +#endif + #include "pci_controller.h" @@ -77,7 +81,7 @@ status_t WritePciConfig(int domain, uint8 bus, uint8 device, uint8 function, uint8 offset, uint8 size, uint32 value); - status_t GetVirtBus(uint8 virt_bus, int *domain, uint8 *bus); + status_t ResolveVirtualBus(uint8 virtualBus, int *domain, uint8 *bus); private: @@ -104,7 +108,7 @@ domain_data * GetDomainData(int domain); - status_t AddVirtBus(int domain, uint8 bus, uint8 *virt_bus); + status_t CreateVirtualBus(int domain, uint8 bus, uint8 *virtualBus); private: PCIBus * fRootBus; @@ -114,6 +118,9 @@ domain_data fDomainData[MAX_PCI_DOMAINS]; int fDomainCount; bool fBusEnumeration; + + VectorMap fVirtualBusMap; + int fNextVirtualBus; }; #endif // __cplusplus @@ -128,9 +135,11 @@ long pci_get_nth_pci_info(long index, pci_info *outInfo); -uint32 pci_read_config(uint8 virt_bus, uint8 device, uint8 function, uint8 offset, uint8 size); -void pci_write_config(uint8 virt_bus, uint8 device, uint8 function, uint8 offset, uint8 size, uint32 value); +uint32 pci_read_config(uint8 virtualBus, uint8 device, uint8 function, uint8 offset, uint8 size); +void pci_write_config(uint8 virtualBus, uint8 device, uint8 function, uint8 offset, uint8 size, uint32 value); +void __pci_resolve_virtual_bus(uint8 virtualBus, int *domain, uint8 *bus); + #ifdef __cplusplus } #endif Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2008-02-10 22:29:42 UTC (rev 23943) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2008-02-10 23:39:35 UTC (rev 23944) @@ -148,10 +148,14 @@ static void print_info_basic(const pci_info *info, bool verbose) { + int domain; + uint8 bus; + + __pci_resolve_virtual_bus(info->bus, &domain, &bus); + TRACE(("PCI: [dom %d, bus %2d] bus %3d, device %2d, function %2d: vendor %04x, device %04x, revision %02x\n", - // XXX this works only as long as PCI manager virtual bus mapping isn't changed: - (info->bus >> 5) /* domain */, (info->bus & 0x1f) /* bus */, - info->bus, info->device, info->function, info->vendor_id, info->device_id, info->revision)); + domain, bus, info->bus /* virtual bus*/, + info->device, info->function, info->vendor_id, info->device_id, info->revision)); TRACE(("PCI: class_base %02x, class_function %02x, class_api %02x\n", info->class_base, info->class_sub, info->class_api)); From mmlr at mlotz.ch Mon Feb 11 00:45:37 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Mon, 11 Feb 2008 00:45:37 +0100 Subject: [Haiku-commits] =?windows-1252?q?r23939_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/private/kernel_src/system/kernel__src/system/kernel/v?= =?windows-1252?q?m?= In-Reply-To: <200802102100.m1AL0F71017229@sheep.berlios.de> Message-ID: <12069257409-BeMail@primary> > Author: mmlr > Date: 2008-02-10 22:00:13 +0100 (Sun, 10 Feb 2008) > New Revision: 23939 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23939&view=rev BTW I managed to checkout the whole Haiku trunk in three runs using the R5 svn binaries with the reworked allocator. In three runs because after a (long) while the network broke up and svn hung. But I could kill svn and cleanly shutdown -r in all cases. There seem to be some big memory leaks as doing an svn checkout eats up a lot of memory that apparently does not get freed when it closes down or is killed. But still, the stability is quite impressive, so I thought I'd mention it here... Regards Michael From stefano.ceccherini at gmail.com Mon Feb 11 08:16:23 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 11 Feb 2008 08:16:23 +0100 Subject: [Haiku-commits] r23939 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <12069257409-BeMail@primary> References: <200802102100.m1AL0F71017229@sheep.berlios.de> <12069257409-BeMail@primary> Message-ID: <894b9700802102316r75c8703dn25b036e1f36af11c@mail.gmail.com> 2008/2/11, Michael Lotz : > BTW I managed to checkout the whole Haiku trunk in three runs using the > R5 svn binaries with the reworked allocator. In three runs because > after a (long) while the network broke up and svn hung. But I could > kill svn and cleanly shutdown -r in all cases. There seem to be some > big memory leaks as doing an svn checkout eats up a lot of memory that > apparently does not get freed when it closes down or is killed. But > still, the stability is quite impressive, so I thought I'd mention it > here... Nice work! From anevilyak at gmail.com Mon Feb 11 19:17:42 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Mon, 11 Feb 2008 12:17:42 -0600 Subject: [Haiku-commits] Haiku-commits Digest, Vol 20, Issue 41 In-Reply-To: References: Message-ID: > > Modified: > haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp > Log: > Fix the build. Apparently this file wasn't recompiled on my end before. > > Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-02-10 21:52:05 UTC (rev 23941) > +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-02-10 21:53:53 UTC (rev 23942) > @@ -12,7 +12,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > > > FYI, config_manager.c has this exact same build problem. Regards, Rene From koki at myhaiku.org Mon Feb 11 21:17:02 2008 From: koki at myhaiku.org (Jorge G. Mare (a.k.a. Koki)) Date: Mon, 11 Feb 2008 12:17:02 -0800 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: References: <200802091326.m19DQTau008612@sheep.berlios.de> Message-ID: <47B0AD3E.30001@myhaiku.org> J?r?me Duval wrote: > 2008/2/9, kirilla at BerliOS : > DeskCalc or 'Desk Calculator' should be just Calculator. We should > avoid clinging to BeOS history, like with the name CodyCam, which > hardly makes any sense anymore, even if you happen to be one of the > few BeOS oldtimers. Dumbing down the app names to generic ones takes away from the "personality" of the OS, can therefore weaken your branding, and it is kind of boring. A little playfulness associated with the history of the project can make the OS more appealing. > Sorry but, for me, these names are ones which mean a non conformist > OS. What do you gain in matching the executable name ? Consistency is important. Unless there is some sort of technical restriction, then it would be better if the app name and the executable name were the same. Cheers, Koki From koki at myhaiku.org Mon Feb 11 21:38:16 2008 From: koki at myhaiku.org (Jorge G. Mare (a.k.a. Koki)) Date: Mon, 11 Feb 2008 12:38:16 -0800 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <1596145847-BeMail@kirilla> References: <1596145847-BeMail@kirilla> Message-ID: <47B0B238.4080107@myhaiku.org> Jonas Sundstr?m wrote: > "Fran?ois Revol" wrote: > ... >> plain English names won't mean much more to a >> non-english speaker anyway... > > I expect Haiku to eventually be translated/localized in its entirety. > This is probably what most people expect; to be given the choice > between English and ones primary language. It would be rude of us to > not try to accomodate them. > > But that's no reason to be careless with the English prototype. It > should constitute best practice and be the authority for localisations > to follow. If there is confusion in the prototype, this confusion will > multiply. > > I'd rather not see Haiku in Swedish turn out as bad as Ubuntu in > Swedish. I have participated in numerous localization projects, and I can say with a high degree of confidence that non-English users don't necessarily translate all the name apps. For example, you can expect apps like Pulse, CodyCam, Icon-O-Matic, etc., not to be translated, and non-English users will still be able to identify by their original name. FWIW, Koki From revol at free.fr Mon Feb 11 22:56:09 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 11 Feb 2008 22:56:09 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23935_-_in_haiku/trunk/src=3A_a?= =?windows-1252?q?pps/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrec?= =?windows-1252?q?order_apps/tv_preferences/screensaver__tests/kits/game/c?= =?windows-1252?q?hart_tests/servers/app/bitmap=5Fdrawing?= In-Reply-To: <47B0AD3E.30001@myhaiku.org> Message-ID: <18759526362-BeMail@laptop> > J?r?me Duval wrote: > > 2008/2/9, kirilla at BerliOS : > > DeskCalc or 'Desk Calculator' should be just Calculator. We should > > avoid clinging to BeOS history, like with the name CodyCam, which > > hardly makes any sense anymore, even if you happen to be one of the > > few BeOS oldtimers. > > Dumbing down the app names to generic ones takes away from the > "personality" of the OS, can therefore weaken your branding, and it > is > kind of boring. A little playfulness associated with the history of > the > project can make the OS more appealing. +1 > > > Sorry but, for me, these names are ones which mean a non conformist > > OS. What do you gain in matching the executable name ? > > Consistency is important. Unless there is some sort of technical > restriction, then it would be better if the app name and the > executable > name were the same. The usual case is compound names where the window shows with spaces, but binary names don't because spaces are generally a very bad idea in the file system. Fran?ois. From koki at myhaiku.org Tue Feb 12 00:06:41 2008 From: koki at myhaiku.org (Jorge G. Mare (a.k.a. Koki)) Date: Mon, 11 Feb 2008 15:06:41 -0800 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <200802091326.m19DQTau008612@sheep.berlios.de> References: <200802091326.m19DQTau008612@sheep.berlios.de> Message-ID: <47B0D501.3040201@myhaiku.org> Hi kirilla, kirilla at BerliOS wrote: > Author: kirilla > Date: 2008-02-09 14:26:28 +0100 (Sat, 09 Feb 2008) > New Revision: 23935 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23935&view=rev > > Modified: > haiku/trunk/src/apps/cdplayer/CDPlayer.cpp > haiku/trunk/src/apps/deskcalc/CalcWindow.cpp > haiku/trunk/src/apps/midiplayer/MidiPlayerWindow.cpp > haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp > haiku/trunk/src/apps/tv/config.h > haiku/trunk/src/apps/tv/tv.rdef > haiku/trunk/src/preferences/screensaver/ScreenSaverWindow.cpp > haiku/trunk/src/tests/kits/game/chart/Chart.cpp > haiku/trunk/src/tests/servers/app/bitmap_drawing/main.cpp > Log: > The title of the (primary) window of (non-document) apps and preferences should be the filename of the executable. File and window names should be changed in tandem in the future. All IMO. Sorry, Marcus, for changing TV-O-Rama. :/ We may want to consider using more proper language, e.g. 'Screensaver' or 'Screen Saver' instead of 'ScreenSaver'. DeskCalc or 'Desk Calculator' should be just Calculator. We should avoid clinging to BeOS history, like with the name CodyCam, which hardly makes any sense anymore, even if you happen to be one of the few BeOS oldtimers. I just noticed the original message of this thread, where the names have already been changed. May I (as gently as possible :) ) suggest that you ask before making this sort of changes? Not that I am for or against them, but I think the flow for this sort of thing should be to propose, discuss and then act based on the result of the discussion, not the other way around. :) Cheers, Koki From mmu_man at mail.berlios.de Tue Feb 12 00:09:56 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 12 Feb 2008 00:09:56 +0100 Subject: [Haiku-commits] r23945 - haiku/trunk/src/add-ons/kernel/bus_managers/config_manager Message-ID: <200802112309.m1BN9uc3025041@sheep.berlios.de> Author: mmu_man Date: 2008-02-12 00:09:56 +0100 (Tue, 12 Feb 2008) New Revision: 23945 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23945&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/config_manager/config_manager.c Log: Fix build after mmlr's heap change. Thanks Ren?\195?\169! Modified: haiku/trunk/src/add-ons/kernel/bus_managers/config_manager/config_manager.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/config_manager/config_manager.c 2008-02-10 23:39:35 UTC (rev 23944) +++ haiku/trunk/src/add-ons/kernel/bus_managers/config_manager/config_manager.c 2008-02-11 23:09:56 UTC (rev 23945) @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include From jonas at kirilla.com Mon Feb 11 23:17:22 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Mon, 11 Feb 2008 23:17:22 +0100 CET Subject: [Haiku-commits] =?iso-8859-1?q?r23935_-_in_haiku/trunk/src=3A_app?= =?iso-8859-1?q?s/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrecorde?= =?iso-8859-1?q?r_apps/tv_preferences/screensaver__tests/kits/game/chart_t?= =?iso-8859-1?q?ests/servers/app/bitmap=5Fdrawing?= In-Reply-To: <47B0AD3E.30001@myhaiku.org> Message-ID: <19479525345-BeMail@kirilla> "Jorge G. Mare (a.k.a. Koki)" wrote: > J?r?me Duval wrote: > > 2008/2/9, kirilla at BerliOS : > > DeskCalc or 'Desk Calculator' should be just Calculator. We should > > avoid clinging to BeOS history, like with the name CodyCam, which > > hardly makes any sense anymore, even if you happen to be one of the > > few BeOS oldtimers. > > Dumbing down the app names to generic ones It's not about dumbing down the names. I'm trying to make a case for clarity and precision and I think this can be done without removing the essence of Haiku. > takes away from the "personality" of the OS, can > therefore weaken your branding, and it is kind of > boring. A little playfulness associated with the history > of the project can make the OS more appealing. I'm sorry for my cynicism, but the history of BeOS, or even that of Haiku, won't mean much to the masses which Haiku aspire to appeal to. There would be -plenty- of soul left in Haiku even with CodyCam renamed to something else. Anyway, I suspect CodyCam will be demoted to the demo folder (or a utility folder) once a truly useful line-up of applications can be presented with Haiku, (browser, chat client, spreadsheet, the usual) /Jonas. From colacoder at mail.berlios.de Tue Feb 12 00:48:07 2008 From: colacoder at mail.berlios.de (colacoder at BerliOS) Date: Tue, 12 Feb 2008 00:48:07 +0100 Subject: [Haiku-commits] r23946 - in haiku/trunk/src: add-ons/print/transports/parallel_port add-ons/print/transports/serial_port add-ons/print/transports/usb_port preferences/print Message-ID: <200802112348.m1BNm71E027468@sheep.berlios.de> Author: colacoder Date: 2008-02-12 00:48:05 +0100 (Tue, 12 Feb 2008) New Revision: 23946 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23946&view=rev Modified: haiku/trunk/src/add-ons/print/transports/parallel_port/ParallelTransport.cpp haiku/trunk/src/add-ons/print/transports/serial_port/SerialTransport.cpp haiku/trunk/src/add-ons/print/transports/usb_port/USBTransport.cpp haiku/trunk/src/preferences/print/AddPrinterDialog.cpp haiku/trunk/src/preferences/print/AddPrinterDialog.h Log: Use new transport callbacks from printer preference.... transport addons now choose what to publish in the printers pref add printer dialog... Modified: haiku/trunk/src/add-ons/print/transports/parallel_port/ParallelTransport.cpp =================================================================== --- haiku/trunk/src/add-ons/print/transports/parallel_port/ParallelTransport.cpp 2008-02-11 23:09:56 UTC (rev 23945) +++ haiku/trunk/src/add-ons/print/transports/parallel_port/ParallelTransport.cpp 2008-02-11 23:48:05 UTC (rev 23946) @@ -108,3 +108,22 @@ delete transport; return NULL; } + +status_t list_transport_ports(BMessage* msg) +{ + BDirectory dir("/dev/parallel"); + status_t rc; + + if ((rc=dir.InitCheck()) != B_OK) + return rc; + + if ((rc=dir.Rewind()) != B_OK) + return rc; + + entry_ref ref; + while(dir.GetNextRef(&ref) == B_OK) + msg->AddString("port_id", ref.name); + + return B_OK; +} + Modified: haiku/trunk/src/add-ons/print/transports/serial_port/SerialTransport.cpp =================================================================== --- haiku/trunk/src/add-ons/print/transports/serial_port/SerialTransport.cpp 2008-02-11 23:09:56 UTC (rev 23945) +++ haiku/trunk/src/add-ons/print/transports/serial_port/SerialTransport.cpp 2008-02-11 23:48:05 UTC (rev 23946) @@ -109,3 +109,22 @@ delete transport; return NULL; } + +status_t list_transport_ports(BMessage* msg) +{ + BDirectory dir("/dev/ports"); + status_t rc; + + if ((rc=dir.InitCheck()) != B_OK) + return rc; + + if ((rc=dir.Rewind()) != B_OK) + return rc; + + entry_ref ref; + while(dir.GetNextRef(&ref) == B_OK) + msg->AddString("port_id", ref.name); + + return B_OK; +} + Modified: haiku/trunk/src/add-ons/print/transports/usb_port/USBTransport.cpp =================================================================== --- haiku/trunk/src/add-ons/print/transports/usb_port/USBTransport.cpp 2008-02-11 23:09:56 UTC (rev 23945) +++ haiku/trunk/src/add-ons/print/transports/usb_port/USBTransport.cpp 2008-02-11 23:48:05 UTC (rev 23946) @@ -75,7 +75,25 @@ return NULL; } +status_t list_transport_ports(BMessage* msg) +{ + BDirectory dir("/dev/printer/usb"); + status_t rc; + if ((rc=dir.InitCheck()) != B_OK) + return rc; + + if ((rc=dir.Rewind()) != B_OK) + return rc; + + entry_ref ref; + while(dir.GetNextRef(&ref) == B_OK) + msg->AddString("port_id", ref.name); + + return B_OK; +} + + // Implementation of USBTransport USBTransport::USBTransport(BDirectory *printer, BMessage *msg) Modified: haiku/trunk/src/preferences/print/AddPrinterDialog.cpp =================================================================== --- haiku/trunk/src/preferences/print/AddPrinterDialog.cpp 2008-02-11 23:09:56 UTC (rev 23945) +++ haiku/trunk/src/preferences/print/AddPrinterDialog.cpp 2008-02-11 23:48:05 UTC (rev 23946) @@ -26,6 +26,7 @@ #include #include +#include AddPrinterDialog::AddPrinterDialog(BWindow *parent) : Inherited(BRect(78.0, 71.0, 400, 300), "Add Printer", @@ -218,7 +219,7 @@ panel->AddChild(transportMenuField); transportMenuField->GetPreferredSize(&w, &h); transportMenuField->ResizeTo(r.Width(), h); - FillMenu(fTransport, "Print/transport", kTransportSelectedMsg); + FillTransportMenu(fTransport); r.OffsetBy(0, transportMenuField->Bounds().Height() + kVMargin); @@ -325,7 +326,6 @@ #endif }; - void AddPrinterDialog::FillMenu(BMenu* menu, const char* path, uint32 what) { @@ -363,72 +363,77 @@ if (entry.GetPath(&path) != B_OK) continue; - bool addMenuItem = true; - // some hard coded special cases for transport add-ons - if (menu == fTransport) { - const char* transport = path.Leaf(); - // Network not implemented yet! - if (strcmp(transport, "Network") == 0) - continue; - - addMenuItem = false; - - if (strcmp(transport, "Serial Port") == 0) { - AddPortSubMenu(menu, transport, "/dev/ports"); - } else if (strcmp(transport, "Parallel Port") == 0) { - AddPortSubMenu(menu, transport, "/dev/parallel"); - } else if (strcmp(transport, "USB Port") == 0) { - AddPortSubMenu(menu, transport, "/dev/printer/usb"); - } else { - addMenuItem = true; - } - } - - if (addMenuItem) { - BMessage* msg = new BMessage(what); - msg->AddString("name", path.Leaf()); - menu->AddItem(new BMenuItem(path.Leaf(), msg)); - } + BMessage* msg = new BMessage(what); + msg->AddString("name", path.Leaf()); + menu->AddItem(new BMenuItem(path.Leaf(), msg)); } } } - -void -AddPrinterDialog::AddPortSubMenu(BMenu* menu, const char* transport, const char* port) +void AddPrinterDialog::FillTransportMenu(BMenu* menu) { - BEntry entry(port); - BDirectory dir(&entry); - if (dir.InitCheck() != B_OK) + BMessenger msgr; + if (GetPrinterServerMessenger(msgr) != B_OK) return; - BMenu* subMenu = NULL; - BPath path; - while (dir.GetNextEntry(&entry) == B_OK) { - if (entry.GetPath(&path) != B_OK) + for (long idx=0; ; idx++) { + BMessage reply, msg(B_GET_PROPERTY); + msg.AddSpecifier("Transport", idx); + if (msgr.SendMessage(&msg,&reply) != B_OK) + break; + + BMessenger transport; + if (reply.FindMessenger("result", &transport) != B_OK) + break; + + // Got messenger to transport now + msg.MakeEmpty(); + msg.what = B_GET_PROPERTY; + msg.AddSpecifier("Name"); + if (transport.SendMessage(&msg,&reply) != B_OK) continue; - // lazily create sub menu - if (subMenu == NULL) { - subMenu = new BMenu(transport); - menu->AddItem(subMenu); - subMenu->SetRadioMode(true); - int32 index = menu->IndexOf(subMenu); - BMenuItem* item = menu->ItemAt(index); - if (item != NULL) - item->SetMessage(new BMessage(kTransportSelectedMsg)); + BString transportName; + if (reply.FindString("result",&transportName) != B_OK) + continue; + + // Now get ports... + BString portId, portName; + status_t err; + msg.MakeEmpty(); + msg.what = B_GET_PROPERTY; + msg.AddSpecifier("Ports"); + if (transport.SendMessage(&msg,&reply) != B_OK || + reply.FindString("port_id", &portId) != B_OK) { + // Can't find ports; so just show transport item, no menu + BMessage* menuMsg = new BMessage(kTransportSelectedMsg); + menuMsg->AddString("name", transportName); + menu->AddItem(new BMenuItem(transportName.String(), menuMsg)); + continue; } - // setup menu item for port - BMessage* msg = new BMessage(kTransportSelectedMsg); - msg->AddString("name", transport); - msg->AddString("path", path.Leaf()); - BMenuItem* item = new BMenuItem(path.Leaf(), msg); - subMenu->AddItem(item); + // We have at least one port; so create submenu + BMenu* transportMenu = new BMenu(transportName.String()); + menu->AddItem(transportMenu); + transportMenu->SetRadioMode(true); + menu->ItemAt(menu->IndexOf(transportMenu))-> + SetMessage(new BMessage(kTransportSelectedMsg)); + + for (int32 pidx=0; reply.FindString("port_id", pidx, &portId) == B_OK; pidx++) { + reply.FindString("port_name", pidx, &portName); + + if (!portName.Length()) + portName = portId; + + // Create menu item in submenu for port + BMessage* portMsg = new BMessage(kTransportSelectedMsg); + portMsg->AddString("name", transportName); + portMsg->AddString("path", portId); + transportMenu->AddItem(new BMenuItem(portName.String(), portMsg)); + } } } - void AddPrinterDialog::Update() { Modified: haiku/trunk/src/preferences/print/AddPrinterDialog.h =================================================================== --- haiku/trunk/src/preferences/print/AddPrinterDialog.h 2008-02-11 23:09:56 UTC (rev 23945) +++ haiku/trunk/src/preferences/print/AddPrinterDialog.h 2008-02-11 23:48:05 UTC (rev 23946) @@ -41,6 +41,7 @@ void HandleChangedTransport(BMessage *msg); void BuildGUI(int stage); + void FillTransportMenu(BMenu *menu); void FillMenu(BMenu *menu, const char *path, uint32 what); void AddPortSubMenu(BMenu *menu, const char *transport, const char *port); void Update(); From jonas at kirilla.com Tue Feb 12 00:00:02 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Tue, 12 Feb 2008 00:00:02 +0100 CET Subject: [Haiku-commits] =?iso-8859-1?q?r23935_-_in_haiku/trunk/src=3A_app?= =?iso-8859-1?q?s/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrecorde?= =?iso-8859-1?q?r_apps/tv_preferences/screensaver__tests/kits/game/chart_t?= =?iso-8859-1?q?ests/servers/app/bitmap=5Fdrawing?= In-Reply-To: <47B0D501.3040201@myhaiku.org> Message-ID: <22039328080-BeMail@kirilla> "Jorge G. Mare (a.k.a. Koki)" wrote: > Hi kirilla, ... > > Log: > > The title of the (primary) window of (non-document) > > apps and preferences should be the filename of the > > executable. I think its pretty standard, logical and acceptable that the name of the application should be the same regardless of where its presented, be it filename, window tab, about- window or some other place. ... > > Sorry, Marcus, for changing TV-O-Rama. :/ Maybe I overstepped my informal boundaries, but as I see it Marcus has given the app to Haiku. The project as a whole has ownership and is free to rename it. I am not the project, but the project is moved forward by individual commits, and usually not by discussion. Feel free to revert though. I fully understand if Marcus wants his creation to be called TV-O-Rama and if other people want to respect his wishes, or simply consider TV-O-Rama to be a good name. For the record though, IIRC, the filename of TV-O-Rama was "TV", as was the link to it in Haiku's application menu. The jam target is "TV" and the source folder is "tv". So I changed TV-O-Rama to match the filename, just like the rest of the apps in my commit. > We may want to consider using more proper language, > e.g. 'Screensaver' or 'Screen Saver' instead of > 'ScreenSaver'. ... > I just noticed the original message of this thread, where > the names have already been changed. FWIW, I merely removed inconsistency in the names. (I didn't invent new names.) > May I (as gently as possible :) ) suggest that you ask > before making this sort of changes? Consider my commits suggestions. These aren't large changes, really, but it's necessary polish, IMO. > Not that I am for or against them, but I think the flow for > this sort of thing should be to propose, discuss and then > act based on the result of the discussion, not the other > way around. :) I wish I had all that time back which I spent over the years on the BeOS mailinglists in endless and fruitless discussion. The people who just go ahead and do stuff usually succeed. I agree that many things need consensus, but its a lot more efficient to allow the people who care the most to drive development of the areas where consensus isn't crucial at every incremental step, and it's usually not impossible to revert bad changes. /Jonas. From jonas at kirilla.com Tue Feb 12 00:05:39 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Tue, 12 Feb 2008 00:05:39 +0100 CET Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <18759526362-BeMail@laptop> Message-ID: <22376165425-BeMail@kirilla> "Fran?ois Revol" wrote: > > J?r?me Duval wrote: ... > > Consistency is important. Unless there is some > > sort of technical restriction, then it would be better > > if the app name and the executable name were > > the same. > > The usual case is compound names where the window > shows with spaces, but binary names don't because > spaces are generally a very bad idea in the file system. Autocompletion, proper shell scripting, ?.. Who would be executing, say, "Disk Probe" from the CLI and not know what they're doing? My scope's limited to GUI applications in this thread. /Jonas. From revol at free.fr Tue Feb 12 00:49:47 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Tue, 12 Feb 2008 00:49:47 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23935_-_in_haiku/trunk/src=3A_a?= =?windows-1252?q?pps/cdplayer_apps/deskcalc_apps/midiplayer_apps/soundrec?= =?windows-1252?q?order_apps/tv_preferences/screensaver__tests/kits/game/c?= =?windows-1252?q?hart_tests/servers/app/bitmap=5Fdrawing?= In-Reply-To: <47B0D501.3040201@myhaiku.org> Message-ID: <25577830452-BeMail@laptop> > I just noticed the original message of this thread, where the names > have > already been changed. > > May I (as gently as possible :) ) suggest that you ask before making > this sort of changes? Not that I am for or against them, but I think > the > flow for this sort of thing should be to propose, discuss and then > act > based on the result of the discussion, not the other way around. :) > +1. Btw, some applications also rely on the window names of other applications (with scripting), so that kind of things must always be done with care. Fran?ois. From jonas at kirilla.com Tue Feb 12 00:16:30 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Tue, 12 Feb 2008 00:16:30 +0100 CET Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <47B0B238.4080107@myhaiku.org> Message-ID: <23027334203-BeMail@kirilla> "Jorge G. Mare (a.k.a. Koki)" wrote: ... > I have participated in numerous localization projects, > and I can say with a high degree of confidence that > non-English users don't necessarily translate all the > name apps. For example, you can expect apps like > Pulse, CodyCam, Icon-O-Matic, etc., not to be translated, > and non-English users will still be able to identify by > their original name. Yes, people always get by somehow. But if those names were less monolithic, less name-ish, they could more easily be localized, and that would probably benefit a lot of people. (English may not be the primary international language 20 years from now.) /Jonas. From koki at myhaiku.org Tue Feb 12 01:33:21 2008 From: koki at myhaiku.org (Jorge G. Mare (a.k.a. Koki)) Date: Mon, 11 Feb 2008 16:33:21 -0800 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <23027334203-BeMail@kirilla> References: <23027334203-BeMail@kirilla> Message-ID: <47B0E951.4040503@myhaiku.org> Hi Jonas, Jonas Sundstr?m wrote: > "Jorge G. Mare (a.k.a. Koki)" wrote: > ... >> I have participated in numerous localization projects, >> and I can say with a high degree of confidence that >> non-English users don't necessarily translate all the >> name apps. For example, you can expect apps like >> Pulse, CodyCam, Icon-O-Matic, etc., not to be translated, >> and non-English users will still be able to identify by >> their original name. > > Yes, people always get by somehow. > > But if those names were less monolithic, less name-ish, > they could more easily be localized, and that would > probably benefit a lot of people. (English may not be > the primary international language 20 years from now.) It's not really that people are being forced to get by. In many cases users (and even businesses who market software) simply prefer to use the English names for various reasons (ie., the cool factor, because it is more practical, easier to support, etc.). This sort of differentiation actually helps you build your brand. All IMHO and FWIW disclaimers apply. :) Cheers, Koki From mmlr at mail.berlios.de Tue Feb 12 01:54:04 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 12 Feb 2008 01:54:04 +0100 Subject: [Haiku-commits] r23947 - in haiku/trunk/src: build/libbe/storage/mime tools/fs_shell Message-ID: <200802120054.m1C0s4Hn019625@sheep.berlios.de> Author: mmlr Date: 2008-02-12 01:54:04 +0100 (Tue, 12 Feb 2008) New Revision: 23947 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23947&view=rev Modified: haiku/trunk/src/build/libbe/storage/mime/database_support.cpp haiku/trunk/src/tools/fs_shell/command_cp.cpp Log: Two very small changes that help compiling Haiku under Haiku. Modified: haiku/trunk/src/build/libbe/storage/mime/database_support.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/mime/database_support.cpp 2008-02-11 23:48:05 UTC (rev 23946) +++ haiku/trunk/src/build/libbe/storage/mime/database_support.cpp 2008-02-12 00:54:04 UTC (rev 23947) @@ -29,11 +29,13 @@ #define DBG(x) #define OUT printf +#ifndef HAIKU_HOST_PLATFORM_HAIKU // icon types (which really ought to be publicly or semi-publicly declared somewhere...) enum { B_MINI_ICON_TYPE = 'MICN', B_LARGE_ICON_TYPE = 'ICON', }; +#endif namespace BPrivate { namespace Storage { Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/command_cp.cpp 2008-02-11 23:48:05 UTC (rev 23946) +++ haiku/trunk/src/tools/fs_shell/command_cp.cpp 2008-02-12 00:54:04 UTC (rev 23947) @@ -9,6 +9,7 @@ #include #include +#include #include #include From mmlr at mlotz.ch Tue Feb 12 02:01:56 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Tue, 12 Feb 2008 02:01:56 +0100 Subject: [Haiku-commits] =?windows-1252?q?r23947_-_in_haiku/trunk/src=3A_b?= =?windows-1252?q?uild/libbe/storage/mime_tools/fs=5Fshell?= In-Reply-To: <200802120054.m1C0s4Hn019625@sheep.berlios.de> Message-ID: <2801134143-BeMail@primary> > Author: mmlr > Date: 2008-02-12 01:54:04 +0100 (Tue, 12 Feb 2008) > New Revision: 23947 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23947&view=rev > Log: > Two very small changes that help compiling Haiku under Haiku. Well, that's all what I've come up with after a Haiku session with an uptime of more than 5 hours, compiling my first haiku-image under Haiku from a tree checked out under Haiku. I even tested that the image boots and works using QEMU which I copied over from my BeOS partition (including using kqemu that was dropped in from there too and was simply picked up when starting QEMU). Sure, I used the compiler and flex from R5 and maybe employed _one_ small hack*, but hey that's pretty close to self-hosting. If we find all the involved memory leaks and fix the svn crash on exit that would be great. Anyway, I'm calling it a day now and finally go to sleep... Regards Michael * Somehow string/endian.h couldn't be opened (B_NOT_ALLOWED) so I symlinked "src/system/libroot/posix/glibc/string" into "src/system/ libroot/posix/glibc/include" and named it "string2" (otherwise it would clash with "" includes - including a directory...) and changed "src/system/libroot/posix/glibc/include/endian.h" accordingly to include "". This was required to get libroot to compile. I am sure there is a correct way to fix that and even a simpler way to work around it, but I was just somewhat impatient... From leavengood at gmail.com Tue Feb 12 04:08:51 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 11 Feb 2008 22:08:51 -0500 Subject: [Haiku-commits] r23947 - in haiku/trunk/src: build/libbe/storage/mime tools/fs_shell In-Reply-To: <2801134143-BeMail@primary> References: <200802120054.m1C0s4Hn019625@sheep.berlios.de> <2801134143-BeMail@primary> Message-ID: On Feb 11, 2008 8:01 PM, Michael Lotz wrote: > > Well, that's all what I've come up with after a Haiku session with an > uptime of more than 5 hours, compiling my first haiku-image under Haiku > from a tree checked out under Haiku. Um, wow! I'm thinking this might be important enough to post about on the Haiku web site! ;) Maybe only after a few other people get it working too? Ryan From mmlr at mlotz.ch Tue Feb 12 09:11:38 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Tue, 12 Feb 2008 09:11:38 +0100 Subject: [Haiku-commits] r23947 - in haiku/trunk/src: build/libbe/storage/mime tools/fs_shell In-Reply-To: References: <200802120054.m1C0s4Hn019625@sheep.berlios.de> <2801134143-BeMail@primary> Message-ID: <20080212080255.M75379@mlotz.ch> On Mon, 11 Feb 2008 22:08:51 -0500, Ryan Leavengood wrote > On Feb 11, 2008 8:01 PM, Michael Lotz wrote: > > > > Well, that's all what I've come up with after a Haiku session with an > > uptime of more than 5 hours, compiling my first haiku-image under Haiku > > from a tree checked out under Haiku. > > Um, wow! I'm thinking this might be important enough to post about on > the Haiku web site! ;) Well, it's certainly a nice milestone (if we even want to call it that), but I don't think we need to hype it. Haiku's just become pretty stable and nice to work/develop on. But it's certainly not there yet. As I said there are numerous memory leaks (or maybe it's just the new allocator who messes up things...) that prevent doing everything in one go. So we're not exactly selfhosting, just close to it. Anyway, using the R5 buildtools is not really what we aim at. The toolchain will be ported to Haiku natively so it can be installed without removing R5 specifics from a compiler that does things not really necessary for Haiku. Only with native buildtools and when we reach a point where we can do a full cycle without having to reboot we can start calling it selfhosting. Regards Michael From jackburton at mail.berlios.de Tue Feb 12 09:48:04 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 12 Feb 2008 09:48:04 +0100 Subject: [Haiku-commits] r23948 - in haiku/vendor: . bash bash/current bash/current/CWRU bash/current/CWRU/misc bash/current/builtins bash/current/cross-build bash/current/doc bash/current/examples bash/current/examples/bashdb bash/current/examples/complete bash/current/examples/functions bash/current/examples/loadables bash/current/examples/loadables/perl bash/current/examples/misc bash/current/examples/obashdb bash/current/examples/scripts bash/current/examples/scripts.noah bash/current/examples/scripts.v2 bash/current/examples/startup-files bash/current/examples/startup-files/apple bash/current/include bash/current/lib bash/current/lib/glob bash/current/lib/glob/doc bash/current/lib/malloc bash/current/lib/readline bash/current/lib/readline/doc bash/current/lib/readline/examples bash/current/lib/sh bash/current/lib/termcap bash/current/lib/termcap/grot bash/current/lib/tilde bash/current/lib/tilde/doc bash/current/support bash/current/tests bash/current/tests/misc Message-ID: <200802120848.m1C8m4Hk010965@sheep.berlios.de> Author: jackburton Date: 2008-02-12 09:40:46 +0100 (Tue, 12 Feb 2008) New Revision: 23948 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23948&view=rev Added: haiku/vendor/bash/ haiku/vendor/bash/current/ haiku/vendor/bash/current/AUTHORS haiku/vendor/bash/current/CHANGES haiku/vendor/bash/current/COMPAT haiku/vendor/bash/current/COPYING haiku/vendor/bash/current/CWRU/ haiku/vendor/bash/current/CWRU/PLATFORMS haiku/vendor/bash/current/CWRU/README haiku/vendor/bash/current/CWRU/changelog haiku/vendor/bash/current/CWRU/mh-folder-comp haiku/vendor/bash/current/CWRU/misc/ haiku/vendor/bash/current/CWRU/misc/bison haiku/vendor/bash/current/CWRU/misc/errlist.c haiku/vendor/bash/current/CWRU/misc/hpux10-dlfcn.h haiku/vendor/bash/current/CWRU/misc/open-files.c haiku/vendor/bash/current/CWRU/misc/sigs.c haiku/vendor/bash/current/CWRU/misc/sigstat.c haiku/vendor/bash/current/CWRU/sh-redir-hack haiku/vendor/bash/current/INSTALL haiku/vendor/bash/current/MANIFEST haiku/vendor/bash/current/Makefile.in haiku/vendor/bash/current/NEWS haiku/vendor/bash/current/NOTES haiku/vendor/bash/current/POSIX haiku/vendor/bash/current/RBASH haiku/vendor/bash/current/README haiku/vendor/bash/current/Y2K haiku/vendor/bash/current/aclocal.m4 haiku/vendor/bash/current/alias.c haiku/vendor/bash/current/alias.h haiku/vendor/bash/current/array.c haiku/vendor/bash/current/array.h haiku/vendor/bash/current/arrayfunc.c haiku/vendor/bash/current/arrayfunc.h haiku/vendor/bash/current/bashansi.h haiku/vendor/bash/current/bashhist.c haiku/vendor/bash/current/bashhist.h haiku/vendor/bash/current/bashintl.h haiku/vendor/bash/current/bashjmp.h haiku/vendor/bash/current/bashline.c haiku/vendor/bash/current/bashline.h haiku/vendor/bash/current/bashtypes.h haiku/vendor/bash/current/bracecomp.c haiku/vendor/bash/current/braces.c haiku/vendor/bash/current/builtins.h haiku/vendor/bash/current/builtins/ haiku/vendor/bash/current/builtins/Makefile.in haiku/vendor/bash/current/builtins/alias.def haiku/vendor/bash/current/builtins/bashgetopt.c haiku/vendor/bash/current/builtins/bashgetopt.h haiku/vendor/bash/current/builtins/bind.def haiku/vendor/bash/current/builtins/break.def haiku/vendor/bash/current/builtins/builtin.def haiku/vendor/bash/current/builtins/cd.def haiku/vendor/bash/current/builtins/colon.def haiku/vendor/bash/current/builtins/command.def haiku/vendor/bash/current/builtins/common.c haiku/vendor/bash/current/builtins/common.h haiku/vendor/bash/current/builtins/complete.def haiku/vendor/bash/current/builtins/declare.def haiku/vendor/bash/current/builtins/echo.def haiku/vendor/bash/current/builtins/enable.def haiku/vendor/bash/current/builtins/eval.def haiku/vendor/bash/current/builtins/evalfile.c haiku/vendor/bash/current/builtins/evalstring.c haiku/vendor/bash/current/builtins/exec.def haiku/vendor/bash/current/builtins/exit.def haiku/vendor/bash/current/builtins/fc.def haiku/vendor/bash/current/builtins/fg_bg.def haiku/vendor/bash/current/builtins/getopt.c haiku/vendor/bash/current/builtins/getopt.h haiku/vendor/bash/current/builtins/getopts.def haiku/vendor/bash/current/builtins/hash.def haiku/vendor/bash/current/builtins/help.def haiku/vendor/bash/current/builtins/history.def haiku/vendor/bash/current/builtins/inlib.def haiku/vendor/bash/current/builtins/jobs.def haiku/vendor/bash/current/builtins/kill.def haiku/vendor/bash/current/builtins/let.def haiku/vendor/bash/current/builtins/mkbuiltins.c haiku/vendor/bash/current/builtins/printf.def haiku/vendor/bash/current/builtins/psize.c haiku/vendor/bash/current/builtins/psize.sh haiku/vendor/bash/current/builtins/pushd.def haiku/vendor/bash/current/builtins/read.def haiku/vendor/bash/current/builtins/reserved.def haiku/vendor/bash/current/builtins/return.def haiku/vendor/bash/current/builtins/set.def haiku/vendor/bash/current/builtins/setattr.def haiku/vendor/bash/current/builtins/shift.def haiku/vendor/bash/current/builtins/shopt.def haiku/vendor/bash/current/builtins/source.def haiku/vendor/bash/current/builtins/suspend.def haiku/vendor/bash/current/builtins/test.def haiku/vendor/bash/current/builtins/times.def haiku/vendor/bash/current/builtins/trap.def haiku/vendor/bash/current/builtins/type.def haiku/vendor/bash/current/builtins/ulimit.def haiku/vendor/bash/current/builtins/umask.def haiku/vendor/bash/current/builtins/wait.def haiku/vendor/bash/current/command.h haiku/vendor/bash/current/config-bot.h haiku/vendor/bash/current/config-top.h haiku/vendor/bash/current/config.h.in haiku/vendor/bash/current/configure haiku/vendor/bash/current/configure.in haiku/vendor/bash/current/conftypes.h haiku/vendor/bash/current/copy_cmd.c haiku/vendor/bash/current/cross-build/ haiku/vendor/bash/current/cross-build/beos-sig.h haiku/vendor/bash/current/cross-build/cygwin32.cache haiku/vendor/bash/current/cross-build/opennt.cache haiku/vendor/bash/current/cross-build/win32sig.h haiku/vendor/bash/current/cross-build/x86-beos.cache haiku/vendor/bash/current/dispose_cmd.c haiku/vendor/bash/current/dispose_cmd.h haiku/vendor/bash/current/doc/ haiku/vendor/bash/current/doc/FAQ haiku/vendor/bash/current/doc/INTRO haiku/vendor/bash/current/doc/Makefile.in haiku/vendor/bash/current/doc/README haiku/vendor/bash/current/doc/article.ms haiku/vendor/bash/current/doc/bash.1 haiku/vendor/bash/current/doc/bashbug.1 haiku/vendor/bash/current/doc/bashref.info haiku/vendor/bash/current/doc/bashref.texi haiku/vendor/bash/current/doc/builtins.1 haiku/vendor/bash/current/doc/htmlpost.sh haiku/vendor/bash/current/doc/rbash.1 haiku/vendor/bash/current/doc/texinfo.tex haiku/vendor/bash/current/error.c haiku/vendor/bash/current/error.h haiku/vendor/bash/current/eval.c haiku/vendor/bash/current/examples/ haiku/vendor/bash/current/examples/bashdb/ haiku/vendor/bash/current/examples/bashdb/PERMISSION haiku/vendor/bash/current/examples/bashdb/bashdb haiku/vendor/bash/current/examples/bashdb/bashdb.el haiku/vendor/bash/current/examples/complete/ haiku/vendor/bash/current/examples/complete/complete-examples haiku/vendor/bash/current/examples/complete/complete.freebsd haiku/vendor/bash/current/examples/complete/complete.gnu-longopt haiku/vendor/bash/current/examples/complete/complete.ianmac haiku/vendor/bash/current/examples/complete/complete2.ianmac haiku/vendor/bash/current/examples/functions/ haiku/vendor/bash/current/examples/functions/array-stuff haiku/vendor/bash/current/examples/functions/array-to-string haiku/vendor/bash/current/examples/functions/autoload haiku/vendor/bash/current/examples/functions/autoload.v2 haiku/vendor/bash/current/examples/functions/autoload.v3 haiku/vendor/bash/current/examples/functions/basename haiku/vendor/bash/current/examples/functions/basename2 haiku/vendor/bash/current/examples/functions/coproc.bash haiku/vendor/bash/current/examples/functions/coshell.README haiku/vendor/bash/current/examples/functions/coshell.bash haiku/vendor/bash/current/examples/functions/csh-compat haiku/vendor/bash/current/examples/functions/dirfuncs haiku/vendor/bash/current/examples/functions/dirname haiku/vendor/bash/current/examples/functions/emptydir haiku/vendor/bash/current/examples/functions/exitstat haiku/vendor/bash/current/examples/functions/external haiku/vendor/bash/current/examples/functions/fact haiku/vendor/bash/current/examples/functions/fstty haiku/vendor/bash/current/examples/functions/func haiku/vendor/bash/current/examples/functions/gethtml haiku/vendor/bash/current/examples/functions/getoptx.bash haiku/vendor/bash/current/examples/functions/inetaddr haiku/vendor/bash/current/examples/functions/inpath haiku/vendor/bash/current/examples/functions/isnum.bash haiku/vendor/bash/current/examples/functions/isnum2 haiku/vendor/bash/current/examples/functions/isvalidip haiku/vendor/bash/current/examples/functions/jdate.bash haiku/vendor/bash/current/examples/functions/jj.bash haiku/vendor/bash/current/examples/functions/keep haiku/vendor/bash/current/examples/functions/ksh-cd haiku/vendor/bash/current/examples/functions/ksh-compat-test haiku/vendor/bash/current/examples/functions/kshenv haiku/vendor/bash/current/examples/functions/login haiku/vendor/bash/current/examples/functions/lowercase haiku/vendor/bash/current/examples/functions/manpage haiku/vendor/bash/current/examples/functions/mhfold haiku/vendor/bash/current/examples/functions/notify.bash haiku/vendor/bash/current/examples/functions/pathfuncs haiku/vendor/bash/current/examples/functions/recurse haiku/vendor/bash/current/examples/functions/repeat2 haiku/vendor/bash/current/examples/functions/repeat3 haiku/vendor/bash/current/examples/functions/seq haiku/vendor/bash/current/examples/functions/seq2 haiku/vendor/bash/current/examples/functions/shcat haiku/vendor/bash/current/examples/functions/shcat2 haiku/vendor/bash/current/examples/functions/sort-pos-params haiku/vendor/bash/current/examples/functions/substr haiku/vendor/bash/current/examples/functions/substr2 haiku/vendor/bash/current/examples/functions/term haiku/vendor/bash/current/examples/functions/whatis haiku/vendor/bash/current/examples/functions/whence haiku/vendor/bash/current/examples/functions/which haiku/vendor/bash/current/examples/functions/xalias.bash haiku/vendor/bash/current/examples/functions/xfind.bash haiku/vendor/bash/current/examples/loadables/ haiku/vendor/bash/current/examples/loadables/Makefile.in haiku/vendor/bash/current/examples/loadables/README haiku/vendor/bash/current/examples/loadables/basename.c haiku/vendor/bash/current/examples/loadables/cat.c haiku/vendor/bash/current/examples/loadables/cut.c haiku/vendor/bash/current/examples/loadables/dirname.c haiku/vendor/bash/current/examples/loadables/finfo.c haiku/vendor/bash/current/examples/loadables/getconf.c haiku/vendor/bash/current/examples/loadables/getconf.h haiku/vendor/bash/current/examples/loadables/head.c haiku/vendor/bash/current/examples/loadables/hello.c haiku/vendor/bash/current/examples/loadables/id.c haiku/vendor/bash/current/examples/loadables/ln.c haiku/vendor/bash/current/examples/loadables/logname.c haiku/vendor/bash/current/examples/loadables/mkdir.c haiku/vendor/bash/current/examples/loadables/necho.c haiku/vendor/bash/current/examples/loadables/pathchk.c haiku/vendor/bash/current/examples/loadables/perl/ haiku/vendor/bash/current/examples/loadables/perl/Makefile.in haiku/vendor/bash/current/examples/loadables/perl/README haiku/vendor/bash/current/examples/loadables/perl/bperl.c haiku/vendor/bash/current/examples/loadables/perl/iperl.c haiku/vendor/bash/current/examples/loadables/print.c haiku/vendor/bash/current/examples/loadables/printenv.c haiku/vendor/bash/current/examples/loadables/push.c haiku/vendor/bash/current/examples/loadables/realpath.c haiku/vendor/bash/current/examples/loadables/rmdir.c haiku/vendor/bash/current/examples/loadables/sleep.c haiku/vendor/bash/current/examples/loadables/sync.c haiku/vendor/bash/current/examples/loadables/tee.c haiku/vendor/bash/current/examples/loadables/template.c haiku/vendor/bash/current/examples/loadables/truefalse.c haiku/vendor/bash/current/examples/loadables/tty.c haiku/vendor/bash/current/examples/loadables/uname.c haiku/vendor/bash/current/examples/loadables/unlink.c haiku/vendor/bash/current/examples/loadables/whoami.c haiku/vendor/bash/current/examples/misc/ haiku/vendor/bash/current/examples/misc/aliasconv.bash haiku/vendor/bash/current/examples/misc/aliasconv.sh haiku/vendor/bash/current/examples/misc/cshtobash haiku/vendor/bash/current/examples/misc/suncmd.termcap haiku/vendor/bash/current/examples/obashdb/ haiku/vendor/bash/current/examples/obashdb/PERMISSION haiku/vendor/bash/current/examples/obashdb/README haiku/vendor/bash/current/examples/obashdb/bashdb haiku/vendor/bash/current/examples/obashdb/bashdb.fns haiku/vendor/bash/current/examples/obashdb/bashdb.pre haiku/vendor/bash/current/examples/scripts.noah/ haiku/vendor/bash/current/examples/scripts.noah/PERMISSION haiku/vendor/bash/current/examples/scripts.noah/README haiku/vendor/bash/current/examples/scripts.noah/aref.bash haiku/vendor/bash/current/examples/scripts.noah/bash.sub.bash haiku/vendor/bash/current/examples/scripts.noah/bash_version.bash haiku/vendor/bash/current/examples/scripts.noah/meta.bash haiku/vendor/bash/current/examples/scripts.noah/mktmp.bash haiku/vendor/bash/current/examples/scripts.noah/number.bash haiku/vendor/bash/current/examples/scripts.noah/prompt.bash haiku/vendor/bash/current/examples/scripts.noah/remap_keys.bash haiku/vendor/bash/current/examples/scripts.noah/require.bash haiku/vendor/bash/current/examples/scripts.noah/send_mail.bash haiku/vendor/bash/current/examples/scripts.noah/shcat.bash haiku/vendor/bash/current/examples/scripts.noah/source.bash haiku/vendor/bash/current/examples/scripts.noah/string.bash haiku/vendor/bash/current/examples/scripts.noah/stty.bash haiku/vendor/bash/current/examples/scripts.noah/y_or_n_p.bash haiku/vendor/bash/current/examples/scripts.v2/ haiku/vendor/bash/current/examples/scripts.v2/PERMISSION haiku/vendor/bash/current/examples/scripts.v2/README haiku/vendor/bash/current/examples/scripts.v2/arc2tarz haiku/vendor/bash/current/examples/scripts.v2/bashrand haiku/vendor/bash/current/examples/scripts.v2/cal2day.bash haiku/vendor/bash/current/examples/scripts.v2/cdhist.bash haiku/vendor/bash/current/examples/scripts.v2/corename haiku/vendor/bash/current/examples/scripts.v2/fman haiku/vendor/bash/current/examples/scripts.v2/frcp haiku/vendor/bash/current/examples/scripts.v2/lowercase haiku/vendor/bash/current/examples/scripts.v2/ncp haiku/vendor/bash/current/examples/scripts.v2/newext haiku/vendor/bash/current/examples/scripts.v2/nmv haiku/vendor/bash/current/examples/scripts.v2/pages haiku/vendor/bash/current/examples/scripts.v2/pf haiku/vendor/bash/current/examples/scripts.v2/pmtop haiku/vendor/bash/current/examples/scripts.v2/ren haiku/vendor/bash/current/examples/scripts.v2/rename haiku/vendor/bash/current/examples/scripts.v2/repeat haiku/vendor/bash/current/examples/scripts.v2/shprof haiku/vendor/bash/current/examples/scripts.v2/untar haiku/vendor/bash/current/examples/scripts.v2/uudec haiku/vendor/bash/current/examples/scripts.v2/uuenc haiku/vendor/bash/current/examples/scripts.v2/vtree haiku/vendor/bash/current/examples/scripts.v2/where haiku/vendor/bash/current/examples/scripts/ haiku/vendor/bash/current/examples/scripts/adventure.sh haiku/vendor/bash/current/examples/scripts/bcsh.sh haiku/vendor/bash/current/examples/scripts/cat.sh haiku/vendor/bash/current/examples/scripts/center haiku/vendor/bash/current/examples/scripts/dd-ex.sh haiku/vendor/bash/current/examples/scripts/fixfiles.bash haiku/vendor/bash/current/examples/scripts/hanoi.bash haiku/vendor/bash/current/examples/scripts/inpath haiku/vendor/bash/current/examples/scripts/krand.bash haiku/vendor/bash/current/examples/scripts/line-input.bash haiku/vendor/bash/current/examples/scripts/nohup.bash haiku/vendor/bash/current/examples/scripts/precedence haiku/vendor/bash/current/examples/scripts/randomcard.bash haiku/vendor/bash/current/examples/scripts/scrollbar haiku/vendor/bash/current/examples/scripts/scrollbar2 haiku/vendor/bash/current/examples/scripts/self-repro haiku/vendor/bash/current/examples/scripts/showperm.bash haiku/vendor/bash/current/examples/scripts/shprompt haiku/vendor/bash/current/examples/scripts/spin.bash haiku/vendor/bash/current/examples/scripts/timeout haiku/vendor/bash/current/examples/scripts/vtree2 haiku/vendor/bash/current/examples/scripts/vtree3 haiku/vendor/bash/current/examples/scripts/vtree3a haiku/vendor/bash/current/examples/scripts/websrv.sh haiku/vendor/bash/current/examples/scripts/xterm_title haiku/vendor/bash/current/examples/scripts/zprintf haiku/vendor/bash/current/examples/startup-files/ haiku/vendor/bash/current/examples/startup-files/Bash_aliases haiku/vendor/bash/current/examples/startup-files/Bash_profile haiku/vendor/bash/current/examples/startup-files/Bashrc.bfox haiku/vendor/bash/current/examples/startup-files/README haiku/vendor/bash/current/examples/startup-files/apple/ haiku/vendor/bash/current/examples/startup-files/apple/README haiku/vendor/bash/current/examples/startup-files/apple/aliases haiku/vendor/bash/current/examples/startup-files/apple/bash.defaults haiku/vendor/bash/current/examples/startup-files/apple/environment haiku/vendor/bash/current/examples/startup-files/apple/login haiku/vendor/bash/current/examples/startup-files/apple/logout haiku/vendor/bash/current/examples/startup-files/apple/rc haiku/vendor/bash/current/examples/startup-files/bash-profile haiku/vendor/bash/current/examples/startup-files/bashrc haiku/vendor/bash/current/execute_cmd.c haiku/vendor/bash/current/execute_cmd.h haiku/vendor/bash/current/expr.c haiku/vendor/bash/current/externs.h haiku/vendor/bash/current/findcmd.c haiku/vendor/bash/current/findcmd.h haiku/vendor/bash/current/flags.c haiku/vendor/bash/current/flags.h haiku/vendor/bash/current/general.c haiku/vendor/bash/current/general.h haiku/vendor/bash/current/hashcmd.c haiku/vendor/bash/current/hashcmd.h haiku/vendor/bash/current/hashlib.c haiku/vendor/bash/current/hashlib.h haiku/vendor/bash/current/include/ haiku/vendor/bash/current/include/ansi_stdlib.h haiku/vendor/bash/current/include/chartypes.h haiku/vendor/bash/current/include/filecntl.h haiku/vendor/bash/current/include/maxpath.h haiku/vendor/bash/current/include/memalloc.h haiku/vendor/bash/current/include/ocache.h haiku/vendor/bash/current/include/posixdir.h haiku/vendor/bash/current/include/posixjmp.h haiku/vendor/bash/current/include/posixstat.h haiku/vendor/bash/current/include/posixtime.h haiku/vendor/bash/current/include/posixwait.h haiku/vendor/bash/current/include/shmbutil.h haiku/vendor/bash/current/include/shtty.h haiku/vendor/bash/current/include/stdc.h haiku/vendor/bash/current/include/systimes.h haiku/vendor/bash/current/include/typemax.h haiku/vendor/bash/current/include/unionwait.h haiku/vendor/bash/current/input.c haiku/vendor/bash/current/input.h haiku/vendor/bash/current/jobs.c haiku/vendor/bash/current/jobs.h haiku/vendor/bash/current/lib/ haiku/vendor/bash/current/lib/glob/ haiku/vendor/bash/current/lib/glob/Makefile.in haiku/vendor/bash/current/lib/glob/collsyms.h haiku/vendor/bash/current/lib/glob/doc/ haiku/vendor/bash/current/lib/glob/doc/Makefile haiku/vendor/bash/current/lib/glob/doc/glob.texi haiku/vendor/bash/current/lib/glob/glob.c haiku/vendor/bash/current/lib/glob/glob.h haiku/vendor/bash/current/lib/glob/glob_loop.c haiku/vendor/bash/current/lib/glob/ndir.h haiku/vendor/bash/current/lib/glob/sm_loop.c haiku/vendor/bash/current/lib/glob/smatch.c haiku/vendor/bash/current/lib/glob/strmatch.c haiku/vendor/bash/current/lib/glob/strmatch.h haiku/vendor/bash/current/lib/glob/xmbsrtowcs.c haiku/vendor/bash/current/lib/malloc/ haiku/vendor/bash/current/lib/malloc/Makefile.in haiku/vendor/bash/current/lib/malloc/alloca.c haiku/vendor/bash/current/lib/malloc/getpagesize.h haiku/vendor/bash/current/lib/malloc/i386-alloca.s haiku/vendor/bash/current/lib/malloc/imalloc.h haiku/vendor/bash/current/lib/malloc/malloc.c haiku/vendor/bash/current/lib/malloc/mstats.h haiku/vendor/bash/current/lib/malloc/shmalloc.h haiku/vendor/bash/current/lib/malloc/stats.c haiku/vendor/bash/current/lib/malloc/stub.c haiku/vendor/bash/current/lib/malloc/table.c haiku/vendor/bash/current/lib/malloc/table.h haiku/vendor/bash/current/lib/malloc/trace.c haiku/vendor/bash/current/lib/malloc/watch.c haiku/vendor/bash/current/lib/malloc/watch.h haiku/vendor/bash/current/lib/malloc/x386-alloca.s haiku/vendor/bash/current/lib/malloc/xleaktrace haiku/vendor/bash/current/lib/malloc/xmalloc.c haiku/vendor/bash/current/lib/readline/ haiku/vendor/bash/current/lib/readline/COPYING haiku/vendor/bash/current/lib/readline/ChangeLog haiku/vendor/bash/current/lib/readline/Makefile.in haiku/vendor/bash/current/lib/readline/README haiku/vendor/bash/current/lib/readline/STANDALONE haiku/vendor/bash/current/lib/readline/ansi_stdlib.h haiku/vendor/bash/current/lib/readline/bind.c haiku/vendor/bash/current/lib/readline/callback.c haiku/vendor/bash/current/lib/readline/chardefs.h haiku/vendor/bash/current/lib/readline/compat.c haiku/vendor/bash/current/lib/readline/complete.c haiku/vendor/bash/current/lib/readline/display.c haiku/vendor/bash/current/lib/readline/doc/ haiku/vendor/bash/current/lib/readline/doc/Makefile haiku/vendor/bash/current/lib/readline/doc/hist.texinfo haiku/vendor/bash/current/lib/readline/doc/hstech.texinfo haiku/vendor/bash/current/lib/readline/doc/hsuser.texinfo haiku/vendor/bash/current/lib/readline/doc/manvers.texinfo haiku/vendor/bash/current/lib/readline/doc/rlman.texinfo haiku/vendor/bash/current/lib/readline/doc/rltech.texinfo haiku/vendor/bash/current/lib/readline/doc/rluser.texinfo haiku/vendor/bash/current/lib/readline/doc/rluserman.texinfo haiku/vendor/bash/current/lib/readline/emacs_keymap.c haiku/vendor/bash/current/lib/readline/examples/ haiku/vendor/bash/current/lib/readline/examples/Inputrc haiku/vendor/bash/current/lib/readline/examples/Makefile haiku/vendor/bash/current/lib/readline/examples/excallback.c haiku/vendor/bash/current/lib/readline/examples/fileman.c haiku/vendor/bash/current/lib/readline/examples/histexamp.c haiku/vendor/bash/current/lib/readline/examples/manexamp.c haiku/vendor/bash/current/lib/readline/examples/rl.c haiku/vendor/bash/current/lib/readline/examples/rlcat.c haiku/vendor/bash/current/lib/readline/examples/rltest.c haiku/vendor/bash/current/lib/readline/funmap.c haiku/vendor/bash/current/lib/readline/histexpand.c haiku/vendor/bash/current/lib/readline/histfile.c haiku/vendor/bash/current/lib/readline/histlib.h haiku/vendor/bash/current/lib/readline/history.c haiku/vendor/bash/current/lib/readline/history.h haiku/vendor/bash/current/lib/readline/histsearch.c haiku/vendor/bash/current/lib/readline/input.c haiku/vendor/bash/current/lib/readline/isearch.c haiku/vendor/bash/current/lib/readline/keymaps.c haiku/vendor/bash/current/lib/readline/keymaps.h haiku/vendor/bash/current/lib/readline/kill.c haiku/vendor/bash/current/lib/readline/macro.c haiku/vendor/bash/current/lib/readline/mbutil.c haiku/vendor/bash/current/lib/readline/misc.c haiku/vendor/bash/current/lib/readline/nls.c haiku/vendor/bash/current/lib/readline/parens.c haiku/vendor/bash/current/lib/readline/posixdir.h haiku/vendor/bash/current/lib/readline/posixjmp.h haiku/vendor/bash/current/lib/readline/posixstat.h haiku/vendor/bash/current/lib/readline/readline.c haiku/vendor/bash/current/lib/readline/readline.h haiku/vendor/bash/current/lib/readline/rlconf.h haiku/vendor/bash/current/lib/readline/rldefs.h haiku/vendor/bash/current/lib/readline/rlmbutil.h haiku/vendor/bash/current/lib/readline/rlprivate.h haiku/vendor/bash/current/lib/readline/rlshell.h haiku/vendor/bash/current/lib/readline/rlstdc.h haiku/vendor/bash/current/lib/readline/rltty.c haiku/vendor/bash/current/lib/readline/rltty.h haiku/vendor/bash/current/lib/readline/rltypedefs.h haiku/vendor/bash/current/lib/readline/rlwinsize.h haiku/vendor/bash/current/lib/readline/savestring.c haiku/vendor/bash/current/lib/readline/search.c haiku/vendor/bash/current/lib/readline/shell.c haiku/vendor/bash/current/lib/readline/signals.c haiku/vendor/bash/current/lib/readline/tcap.h haiku/vendor/bash/current/lib/readline/terminal.c haiku/vendor/bash/current/lib/readline/text.c haiku/vendor/bash/current/lib/readline/tilde.c haiku/vendor/bash/current/lib/readline/tilde.h haiku/vendor/bash/current/lib/readline/undo.c haiku/vendor/bash/current/lib/readline/util.c haiku/vendor/bash/current/lib/readline/vi_keymap.c haiku/vendor/bash/current/lib/readline/vi_mode.c haiku/vendor/bash/current/lib/readline/xmalloc.c haiku/vendor/bash/current/lib/readline/xmalloc.h haiku/vendor/bash/current/lib/sh/ haiku/vendor/bash/current/lib/sh/Makefile.in haiku/vendor/bash/current/lib/sh/clktck.c haiku/vendor/bash/current/lib/sh/clock.c haiku/vendor/bash/current/lib/sh/fmtullong.c haiku/vendor/bash/current/lib/sh/fmtulong.c haiku/vendor/bash/current/lib/sh/fmtumax.c haiku/vendor/bash/current/lib/sh/getcwd.c haiku/vendor/bash/current/lib/sh/getenv.c haiku/vendor/bash/current/lib/sh/inet_aton.c haiku/vendor/bash/current/lib/sh/itos.c haiku/vendor/bash/current/lib/sh/mailstat.c haiku/vendor/bash/current/lib/sh/makepath.c haiku/vendor/bash/current/lib/sh/memset.c haiku/vendor/bash/current/lib/sh/mktime.c haiku/vendor/bash/current/lib/sh/netconn.c haiku/vendor/bash/current/lib/sh/netopen.c haiku/vendor/bash/current/lib/sh/oslib.c haiku/vendor/bash/current/lib/sh/pathcanon.c haiku/vendor/bash/current/lib/sh/pathphys.c haiku/vendor/bash/current/lib/sh/rename.c haiku/vendor/bash/current/lib/sh/setlinebuf.c haiku/vendor/bash/current/lib/sh/shquote.c haiku/vendor/bash/current/lib/sh/shtty.c haiku/vendor/bash/current/lib/sh/snprintf.c haiku/vendor/bash/current/lib/sh/spell.c haiku/vendor/bash/current/lib/sh/strcasecmp.c haiku/vendor/bash/current/lib/sh/strerror.c haiku/vendor/bash/current/lib/sh/strftime.c haiku/vendor/bash/current/lib/sh/strindex.c haiku/vendor/bash/current/lib/sh/stringlist.c haiku/vendor/bash/current/lib/sh/stringvec.c haiku/vendor/bash/current/lib/sh/strpbrk.c haiku/vendor/bash/current/lib/sh/strtod.c haiku/vendor/bash/current/lib/sh/strtoimax.c haiku/vendor/bash/current/lib/sh/strtol.c haiku/vendor/bash/current/lib/sh/strtoll.c haiku/vendor/bash/current/lib/sh/strtoul.c haiku/vendor/bash/current/lib/sh/strtoull.c haiku/vendor/bash/current/lib/sh/strtoumax.c haiku/vendor/bash/current/lib/sh/strtrans.c haiku/vendor/bash/current/lib/sh/times.c haiku/vendor/bash/current/lib/sh/timeval.c haiku/vendor/bash/current/lib/sh/tmpfile.c haiku/vendor/bash/current/lib/sh/vprint.c haiku/vendor/bash/current/lib/sh/xstrchr.c haiku/vendor/bash/current/lib/sh/zcatfd.c haiku/vendor/bash/current/lib/sh/zread.c haiku/vendor/bash/current/lib/sh/zwrite.c haiku/vendor/bash/current/lib/termcap/ haiku/vendor/bash/current/lib/termcap/Makefile.in haiku/vendor/bash/current/lib/termcap/grot/ haiku/vendor/bash/current/lib/termcap/grot/COPYING haiku/vendor/bash/current/lib/termcap/grot/ChangeLog haiku/vendor/bash/current/lib/termcap/grot/INSTALL haiku/vendor/bash/current/lib/termcap/grot/Makefile.in haiku/vendor/bash/current/lib/termcap/grot/NEWS haiku/vendor/bash/current/lib/termcap/grot/README haiku/vendor/bash/current/lib/termcap/grot/configure haiku/vendor/bash/current/lib/termcap/grot/configure.in haiku/vendor/bash/current/lib/termcap/grot/termcap.info haiku/vendor/bash/current/lib/termcap/grot/termcap.info-1 haiku/vendor/bash/current/lib/termcap/grot/termcap.info-2 haiku/vendor/bash/current/lib/termcap/grot/termcap.info-3 haiku/vendor/bash/current/lib/termcap/grot/termcap.info-4 haiku/vendor/bash/current/lib/termcap/grot/termcap.texi haiku/vendor/bash/current/lib/termcap/grot/texinfo.tex haiku/vendor/bash/current/lib/termcap/ltcap.h haiku/vendor/bash/current/lib/termcap/termcap.c haiku/vendor/bash/current/lib/termcap/termcap.h haiku/vendor/bash/current/lib/termcap/tparam.c haiku/vendor/bash/current/lib/termcap/version.c haiku/vendor/bash/current/lib/tilde/ haiku/vendor/bash/current/lib/tilde/Makefile.in haiku/vendor/bash/current/lib/tilde/README haiku/vendor/bash/current/lib/tilde/doc/ haiku/vendor/bash/current/lib/tilde/doc/Makefile haiku/vendor/bash/current/lib/tilde/doc/tilde.texi haiku/vendor/bash/current/lib/tilde/shell.c haiku/vendor/bash/current/lib/tilde/tilde.c haiku/vendor/bash/current/lib/tilde/tilde.h haiku/vendor/bash/current/list.c haiku/vendor/bash/current/locale.c haiku/vendor/bash/current/mailcheck.c haiku/vendor/bash/current/mailcheck.h haiku/vendor/bash/current/make_cmd.c haiku/vendor/bash/current/make_cmd.h haiku/vendor/bash/current/mksyntax.c haiku/vendor/bash/current/nojobs.c haiku/vendor/bash/current/parse.y haiku/vendor/bash/current/parser-built haiku/vendor/bash/current/parser.h haiku/vendor/bash/current/patchlevel.h haiku/vendor/bash/current/pathexp.c haiku/vendor/bash/current/pathexp.h haiku/vendor/bash/current/pathnames.h haiku/vendor/bash/current/pcomplete.c haiku/vendor/bash/current/pcomplete.h haiku/vendor/bash/current/pcomplib.c haiku/vendor/bash/current/print_cmd.c haiku/vendor/bash/current/quit.h haiku/vendor/bash/current/redir.c haiku/vendor/bash/current/redir.h haiku/vendor/bash/current/shell.c haiku/vendor/bash/current/shell.h haiku/vendor/bash/current/sig.c haiku/vendor/bash/current/sig.h haiku/vendor/bash/current/siglist.c haiku/vendor/bash/current/siglist.h haiku/vendor/bash/current/stringlib.c haiku/vendor/bash/current/subst.c haiku/vendor/bash/current/subst.h haiku/vendor/bash/current/support/ haiku/vendor/bash/current/support/Makefile.in haiku/vendor/bash/current/support/SYMLINKS haiku/vendor/bash/current/support/bash.xbm haiku/vendor/bash/current/support/bashbug.sh haiku/vendor/bash/current/support/bashversion.c haiku/vendor/bash/current/support/config.guess haiku/vendor/bash/current/support/config.sub haiku/vendor/bash/current/support/fixlinks haiku/vendor/bash/current/support/install.sh haiku/vendor/bash/current/support/man2html.c haiku/vendor/bash/current/support/missing haiku/vendor/bash/current/support/mkclone haiku/vendor/bash/current/support/mkconffiles haiku/vendor/bash/current/support/mkdirs haiku/vendor/bash/current/support/mksignames.c haiku/vendor/bash/current/support/mkversion.sh haiku/vendor/bash/current/support/printenv.c haiku/vendor/bash/current/support/printenv.sh haiku/vendor/bash/current/support/recho.c haiku/vendor/bash/current/support/rlvers.sh haiku/vendor/bash/current/support/shobj-conf haiku/vendor/bash/current/support/texi2dvi haiku/vendor/bash/current/support/texi2html haiku/vendor/bash/current/support/xenix-link.sh haiku/vendor/bash/current/support/zecho.c haiku/vendor/bash/current/syntax.h haiku/vendor/bash/current/test.c haiku/vendor/bash/current/test.h haiku/vendor/bash/current/tests/ haiku/vendor/bash/current/tests/README haiku/vendor/bash/current/tests/arith-for.right haiku/vendor/bash/current/tests/arith-for.tests haiku/vendor/bash/current/tests/arith.right haiku/vendor/bash/current/tests/arith.tests haiku/vendor/bash/current/tests/array-at-star haiku/vendor/bash/current/tests/array.right haiku/vendor/bash/current/tests/array.tests haiku/vendor/bash/current/tests/array2.right haiku/vendor/bash/current/tests/braces-tests haiku/vendor/bash/current/tests/braces.right haiku/vendor/bash/current/tests/builtins.right haiku/vendor/bash/current/tests/builtins.tests haiku/vendor/bash/current/tests/builtins1.sub haiku/vendor/bash/current/tests/builtins2.sub haiku/vendor/bash/current/tests/cond.right haiku/vendor/bash/current/tests/cond.tests haiku/vendor/bash/current/tests/cprint.right haiku/vendor/bash/current/tests/cprint.tests haiku/vendor/bash/current/tests/dollar-at-star haiku/vendor/bash/current/tests/dollar.right haiku/vendor/bash/current/tests/dstack.right haiku/vendor/bash/current/tests/dstack.tests haiku/vendor/bash/current/tests/dstack2.right haiku/vendor/bash/current/tests/dstack2.tests haiku/vendor/bash/current/tests/errors.right haiku/vendor/bash/current/tests/errors.tests haiku/vendor/bash/current/tests/exec.right haiku/vendor/bash/current/tests/exec1.sub haiku/vendor/bash/current/tests/exec2.sub haiku/vendor/bash/current/tests/exec3.sub haiku/vendor/bash/current/tests/exec4.sub haiku/vendor/bash/current/tests/exec5.sub haiku/vendor/bash/current/tests/exec6.sub haiku/vendor/bash/current/tests/execscript haiku/vendor/bash/current/tests/exp-tests haiku/vendor/bash/current/tests/exp.right haiku/vendor/bash/current/tests/extglob.right haiku/vendor/bash/current/tests/extglob.tests haiku/vendor/bash/current/tests/extglob2.right haiku/vendor/bash/current/tests/extglob2.tests haiku/vendor/bash/current/tests/func.right haiku/vendor/bash/current/tests/func.tests haiku/vendor/bash/current/tests/func1.sub haiku/vendor/bash/current/tests/func2.sub haiku/vendor/bash/current/tests/func3.sub haiku/vendor/bash/current/tests/getopts.right haiku/vendor/bash/current/tests/getopts.tests haiku/vendor/bash/current/tests/getopts1.sub haiku/vendor/bash/current/tests/getopts2.sub haiku/vendor/bash/current/tests/getopts3.sub haiku/vendor/bash/current/tests/getopts4.sub haiku/vendor/bash/current/tests/getopts5.sub haiku/vendor/bash/current/tests/getopts6.sub haiku/vendor/bash/current/tests/getopts7.sub haiku/vendor/bash/current/tests/glob-test haiku/vendor/bash/current/tests/glob.right haiku/vendor/bash/current/tests/glob1.sub haiku/vendor/bash/current/tests/heredoc.right haiku/vendor/bash/current/tests/heredoc.tests haiku/vendor/bash/current/tests/herestr.right haiku/vendor/bash/current/tests/herestr.tests haiku/vendor/bash/current/tests/histexp.right haiku/vendor/bash/current/tests/histexp.tests haiku/vendor/bash/current/tests/history.list haiku/vendor/bash/current/tests/history.right haiku/vendor/bash/current/tests/history.tests haiku/vendor/bash/current/tests/ifs.right haiku/vendor/bash/current/tests/ifs.tests haiku/vendor/bash/current/tests/input-line.sh haiku/vendor/bash/current/tests/input-line.sub haiku/vendor/bash/current/tests/input.right haiku/vendor/bash/current/tests/invert.right haiku/vendor/bash/current/tests/invert.tests haiku/vendor/bash/current/tests/jobs.right haiku/vendor/bash/current/tests/jobs.tests haiku/vendor/bash/current/tests/jobs1.sub haiku/vendor/bash/current/tests/jobs2.sub haiku/vendor/bash/current/tests/jobs3.sub haiku/vendor/bash/current/tests/misc/ haiku/vendor/bash/current/tests/misc/dev-tcp.tests haiku/vendor/bash/current/tests/misc/perf-script haiku/vendor/bash/current/tests/misc/perftest haiku/vendor/bash/current/tests/misc/read-nchars.tests haiku/vendor/bash/current/tests/misc/redir-t2.sh haiku/vendor/bash/current/tests/misc/run-r2.sh haiku/vendor/bash/current/tests/misc/sigint-1.sh haiku/vendor/bash/current/tests/misc/sigint-2.sh haiku/vendor/bash/current/tests/misc/sigint-3.sh haiku/vendor/bash/current/tests/misc/sigint-4.sh haiku/vendor/bash/current/tests/misc/test-minus-e.1 haiku/vendor/bash/current/tests/misc/test-minus-e.2 haiku/vendor/bash/current/tests/misc/wait-bg.tests haiku/vendor/bash/current/tests/more-exp.right haiku/vendor/bash/current/tests/more-exp.tests haiku/vendor/bash/current/tests/new-exp.right haiku/vendor/bash/current/tests/new-exp.tests haiku/vendor/bash/current/tests/new-exp1.sub haiku/vendor/bash/current/tests/new-exp2.sub haiku/vendor/bash/current/tests/new-exp3.sub haiku/vendor/bash/current/tests/nquote.right haiku/vendor/bash/current/tests/nquote.tests haiku/vendor/bash/current/tests/nquote1.right haiku/vendor/bash/current/tests/nquote1.tests haiku/vendor/bash/current/tests/nquote2.right haiku/vendor/bash/current/tests/nquote2.tests haiku/vendor/bash/current/tests/nquote3.right haiku/vendor/bash/current/tests/nquote3.tests haiku/vendor/bash/current/tests/posix2.right haiku/vendor/bash/current/tests/posix2.tests haiku/vendor/bash/current/tests/posixpat.right haiku/vendor/bash/current/tests/posixpat.tests haiku/vendor/bash/current/tests/prec.right haiku/vendor/bash/current/tests/precedence haiku/vendor/bash/current/tests/printf.right haiku/vendor/bash/current/tests/printf.tests haiku/vendor/bash/current/tests/quote.right haiku/vendor/bash/current/tests/quote.tests haiku/vendor/bash/current/tests/read.right haiku/vendor/bash/current/tests/read.tests haiku/vendor/bash/current/tests/read1.sub haiku/vendor/bash/current/tests/read2.sub haiku/vendor/bash/current/tests/read3.sub haiku/vendor/bash/current/tests/read4.sub haiku/vendor/bash/current/tests/redir.right haiku/vendor/bash/current/tests/redir.tests haiku/vendor/bash/current/tests/redir1.sub haiku/vendor/bash/current/tests/redir2.sub haiku/vendor/bash/current/tests/redir3.in1 haiku/vendor/bash/current/tests/redir3.in2 haiku/vendor/bash/current/tests/redir3.sub haiku/vendor/bash/current/tests/redir4.in1 haiku/vendor/bash/current/tests/redir4.sub haiku/vendor/bash/current/tests/redir5.sub haiku/vendor/bash/current/tests/rhs-exp.right haiku/vendor/bash/current/tests/rhs-exp.tests haiku/vendor/bash/current/tests/rsh.right haiku/vendor/bash/current/tests/rsh.tests haiku/vendor/bash/current/tests/run-all haiku/vendor/bash/current/tests/run-arith haiku/vendor/bash/current/tests/run-arith-for haiku/vendor/bash/current/tests/run-array haiku/vendor/bash/current/tests/run-array2 haiku/vendor/bash/current/tests/run-braces haiku/vendor/bash/current/tests/run-builtins haiku/vendor/bash/current/tests/run-cond haiku/vendor/bash/current/tests/run-cprint haiku/vendor/bash/current/tests/run-dirstack haiku/vendor/bash/current/tests/run-dollars haiku/vendor/bash/current/tests/run-errors haiku/vendor/bash/current/tests/run-execscript haiku/vendor/bash/current/tests/run-exp-tests haiku/vendor/bash/current/tests/run-extglob haiku/vendor/bash/current/tests/run-extglob2 haiku/vendor/bash/current/tests/run-func haiku/vendor/bash/current/tests/run-getopts haiku/vendor/bash/current/tests/run-glob-test haiku/vendor/bash/current/tests/run-heredoc haiku/vendor/bash/current/tests/run-herestr haiku/vendor/bash/current/tests/run-histexpand haiku/vendor/bash/current/tests/run-history haiku/vendor/bash/current/tests/run-ifs haiku/vendor/bash/current/tests/run-input-test haiku/vendor/bash/current/tests/run-invert haiku/vendor/bash/current/tests/run-jobs haiku/vendor/bash/current/tests/run-minimal haiku/vendor/bash/current/tests/run-more-exp haiku/vendor/bash/current/tests/run-new-exp haiku/vendor/bash/current/tests/run-nquote haiku/vendor/bash/current/tests/run-nquote1 haiku/vendor/bash/current/tests/run-nquote2 haiku/vendor/bash/current/tests/run-nquote3 haiku/vendor/bash/current/tests/run-posix2 haiku/vendor/bash/current/tests/run-posixpat haiku/vendor/bash/current/tests/run-precedence haiku/vendor/bash/current/tests/run-printf haiku/vendor/bash/current/tests/run-quote haiku/vendor/bash/current/tests/run-read haiku/vendor/bash/current/tests/run-redir haiku/vendor/bash/current/tests/run-rhs-exp haiku/vendor/bash/current/tests/run-rsh haiku/vendor/bash/current/tests/run-set-e haiku/vendor/bash/current/tests/run-shopt haiku/vendor/bash/current/tests/run-strip haiku/vendor/bash/current/tests/run-test haiku/vendor/bash/current/tests/run-tilde haiku/vendor/bash/current/tests/run-trap haiku/vendor/bash/current/tests/run-type haiku/vendor/bash/current/tests/run-varenv haiku/vendor/bash/current/tests/set-e-test haiku/vendor/bash/current/tests/set-e.right haiku/vendor/bash/current/tests/shopt.right haiku/vendor/bash/current/tests/shopt.tests haiku/vendor/bash/current/tests/source1.sub haiku/vendor/bash/current/tests/source2.sub haiku/vendor/bash/current/tests/source3.sub haiku/vendor/bash/current/tests/source4.sub haiku/vendor/bash/current/tests/source5.sub haiku/vendor/bash/current/tests/strip.right haiku/vendor/bash/current/tests/strip.tests haiku/vendor/bash/current/tests/test.right haiku/vendor/bash/current/tests/test.tests haiku/vendor/bash/current/tests/tilde-tests haiku/vendor/bash/current/tests/tilde.right haiku/vendor/bash/current/tests/trap.right haiku/vendor/bash/current/tests/trap.tests haiku/vendor/bash/current/tests/trap1.sub haiku/vendor/bash/current/tests/trap2.sub haiku/vendor/bash/current/tests/trap2a.sub haiku/vendor/bash/current/tests/type.right haiku/vendor/bash/current/tests/type.tests haiku/vendor/bash/current/tests/varenv.right haiku/vendor/bash/current/tests/varenv.sh haiku/vendor/bash/current/tests/varenv1.sub haiku/vendor/bash/current/tests/varenv2.sub haiku/vendor/bash/current/tests/version haiku/vendor/bash/current/tests/version.mini haiku/vendor/bash/current/trap.c haiku/vendor/bash/current/trap.h haiku/vendor/bash/current/unwind_prot.c haiku/vendor/bash/current/unwind_prot.h haiku/vendor/bash/current/variables.c haiku/vendor/bash/current/variables.h haiku/vendor/bash/current/version.c haiku/vendor/bash/current/xmalloc.c haiku/vendor/bash/current/xmalloc.h haiku/vendor/bash/current/y.tab.c haiku/vendor/bash/current/y.tab.h Log: importing bash 2.05b in the vendor branch Added: haiku/vendor/bash/current/AUTHORS =================================================================== --- haiku/vendor/bash/current/AUTHORS 2008-02-12 00:54:04 UTC (rev 23947) +++ haiku/vendor/bash/current/AUTHORS 2008-02-12 08:40:46 UTC (rev 23948) @@ -0,0 +1,453 @@ +# +# Master author manifest for bash +# +# Any files appearing in the bash distribution not listed in this file +# were created by Chet Ramey. +# +# Filename authors (first is original author) +# +README Brian Fox, Chet Ramey +INSTALL Brian Fox, Chet Ramey +COPYING Brian Fox, Chet Ramey +MANIFEST Brian Fox, Chet Ramey +configure Chet Ramey +Makefile.in Brian Fox, Chet Ramey +configure.in Chet Ramey +aclocal.m4 Chet Ramey +config.h.top Chet Ramey +config.h.bot Chet Ramey +config.h.in Chet Ramey +array.c Chet Ramey +print_cmd.c Brian Fox, Chet Ramey +general.c Brian Fox, Chet Ramey +variables.c Brian Fox, Chet Ramey +make_cmd.c Brian Fox, Chet Ramey +copy_cmd.c Brian Fox, Chet Ramey +unwind_prot.c Brian Fox, Chet Ramey +dispose_cmd.c Brian Fox, Chet Ramey +getcwd.c Roland McGrath, Brian Fox, Chet Ramey +bashhist.c Chet Ramey +hash.c Brian Fox, Chet Ramey +parse.y Brian Fox, Chet Ramey +subst.c Brian Fox, Chet Ramey +shell.c Brian Fox, Chet Ramey +sig.c Chet Ramey +trap.c Brian Fox, Chet Ramey +siglist.c Brian Fox, Chet Ramey +version.c Brian Fox, Chet Ramey +flags.c Brian Fox, Chet Ramey +jobs.c Brian Fox, Chet Ramey +input.c Chet Ramey +mailcheck.c Brian Fox, Chet Ramey +pathexp.c Chet Ramey +test.c Brian Fox, Chet Ramey +expr.c Chet Ramey, Brian Fox +alias.c Brian Fox, Chet Ramey +execute_cmd.c Brian Fox, Chet Ramey +bashline.c Brian Fox, Chet Ramey +braces.c Brian Fox, Chet Ramey +bracecomp.c Brian Fox, Chet Ramey, Tom Tromey +nojobs.c Brian Fox, Chet Ramey +vprint.c Chet Ramey +oslib.c Chet Ramey +error.c Brian Fox, Chet Ramey +xmalloc.c Brian Fox, Chet Ramey +alias.h Brian Fox, Chet Ramey +array.h Chet Ramey +builtins.h Brian Fox, Chet Ramey +parser.h Brian Fox, Chet Ramey +variables.h Brian Fox, Chet Ramey +machines.h Brian Fox, Chet Ramey +jobs.h Brian Fox, Chet Ramey +maxpath.h Brian Fox, Chet Ramey +pathexp.h Chet Ramey +mailcheck.h Chet Ramey +filecntl.h Brian Fox, Chet Ramey +hash.h Brian Fox, Chet Ramey +quit.h Brian Fox, Chet Ramey +flags.h Brian Fox, Chet Ramey +shell.h Brian Fox, Chet Ramey +bashjmp.h Chet Ramey +sig.h Chet Ramey +trap.h Brian Fox, Chet Ramey +general.h Brian Fox, Chet Ramey +unwind_prot.h Brian Fox, Chet Ramey +input.h Brian Fox, Chet Ramey +error.h Brian Fox, Chet Ramey +command.h Brian Fox, Chet Ramey +externs.h Chet Ramey +siglist.h Chet Ramey +subst.h Brian Fox, Chet Ramey +dispose_cmd.h Brian Fox, Chet Ramey +bashansi.h Brian Fox, Chet Ramey +make_cmd.h Brian Fox, Chet Ramey +bashhist.h Chet Ramey +bashline.h Chet Ramey +execute_cmd.h Chet Ramey +bashtypes.h Chet Ramey +bashtty.h Chet Ramey +pathnames.h Chet Ramey +y.tab.c Brian Fox, Chet Ramey +y.tab.h Brian Fox, Chet Ramey +parser-built Brian Fox, Chet Ramey +posixstat.h Brian Fox, Chet Ramey +stdc.h Chet Ramey +ansi_stdlib.h Brian Fox, Chet Ramey +memalloc.h Chet Ramey +builtins/ChangeLog Brian Fox, Chet Ramey +builtins/Makefile.in Brian Fox, Chet Ramey +builtins/alias.def Brian Fox, Chet Ramey +builtins/bind.def Brian Fox, Chet Ramey +builtins/break.def Brian Fox, Chet Ramey +builtins/builtin.def Brian Fox, Chet Ramey +builtins/cd.def Brian Fox, Chet Ramey +builtins/colon.def Brian Fox, Chet Ramey +builtins/command.def Brian Fox, Chet Ramey +builtins/common.c Brian Fox, Chet Ramey +builtins/declare.def Brian Fox, Chet Ramey +builtins/echo.def Brian Fox, Chet Ramey +builtins/enable.def Brian Fox, Chet Ramey +builtins/eval.def Brian Fox, Chet Ramey +builtins/exec.def Brian Fox, Chet Ramey +builtins/exit.def Brian Fox, Chet Ramey +builtins/fc.def Brian Fox, Chet Ramey +builtins/fg_bg.def Brian Fox, Chet Ramey +builtins/getopt.c Roland McGrath, Brian Fox, Chet Ramey +builtins/getopt.h Roland McGrath, Brian Fox, Chet Ramey +builtins/getopts.def Brian Fox, Chet Ramey +builtins/hash.def Brian Fox, Chet Ramey +builtins/hashcom.h Brian Fox, Chet Ramey +builtins/help.def Brian Fox, Chet Ramey +builtins/let.def Chet Ramey, Brian Fox +builtins/history.def Brian Fox, Chet Ramey +builtins/jobs.def Brian Fox, Chet Ramey +builtins/kill.def Brian Fox, Chet Ramey +builtins/mkbuiltins.c Brian Fox, Chet Ramey +builtins/pushd.def Brian Fox, Chet Ramey +builtins/read.def Brian Fox, Chet Ramey +builtins/reserved.def Brian Fox, Chet Ramey +builtins/return.def Brian Fox, Chet Ramey +builtins/set.def Brian Fox, Chet Ramey +builtins/setattr.def Brian Fox, Chet Ramey +builtins/shift.def Brian Fox, Chet Ramey +builtins/shopt.def Chet Ramey +builtins/source.def Brian Fox, Chet Ramey +builtins/suspend.def Brian Fox, Chet Ramey +builtins/test.def Brian Fox, Chet Ramey +builtins/times.def Brian Fox, Chet Ramey +builtins/trap.def Brian Fox, Chet Ramey +builtins/type.def Brian Fox, Chet Ramey +builtins/ulimit.def Chet Ramey, Brian Fox +builtins/umask.def Brian Fox, Chet Ramey +builtins/wait.def Brian Fox, Chet Ramey +builtins/psize.c Chet Ramey, Brian Fox +builtins/psize.sh Chet Ramey, Brian Fox +builtins/inlib.def Chet Ramey +builtins/bashgetopt.c Chet Ramey +builtins/common.h Chet Ramey +builtins/bashgetopt.h Chet Ramey +lib/doc-support/texindex.c bug-texinfo at prep.ai.mit.edu, Chet Ramey +lib/doc-support/Makefile.in Chet Ramey +lib/doc-support/getopt.h Roland McGrath +lib/doc-support/getopt.c Roland McGrath +lib/doc-support/getopt1.c Roland McGrath +lib/glob/ChangeLog Brian Fox, Chet Ramey +lib/glob/Makefile.in Brian Fox, Chet Ramey +lib/glob/strmatch.c Roland McGrath, Brian Fox, Chet Ramey +lib/glob/strmatch.h Roland McGrath, Brian Fox, Chet Ramey +lib/glob/glob.c Richard Stallman, Roland McGrath, Brian Fox, Chet Ramey +lib/glob/glob.h Chet Ramey +lib/glob/ndir.h Doug Gwyn, Richard Stallman +lib/glob/doc/Makefile.in Brian Fox, Chet Ramey +lib/glob/doc/glob.texi Brian Fox, Chet Ramey +lib/malloc/Makefile.in Chet Ramey +lib/malloc/alloca.c Doug Gwyn, Richard Stallman, Brian Fox, Chet Ramey +lib/malloc/getpagesize.h Brian Fox, Chet Ramey +lib/malloc/malloc.c Chris Kingsley, Mike Muuss, Richard Stallman, Brian Fox, Chet Ramey +lib/malloc/gmalloc.c Mike Haertel, Roland McGrath +lib/malloc/stub.c Chet Ramey +lib/malloc/i386-alloca.s Richard Stallman +lib/malloc/x386-alloca.s Chip Salzenberg, Richard Stallman +lib/malloc/xmalloc.c Brian Fox, Chet Ramey +lib/posixheaders/posixstat.h Brian Fox, Chet Ramey +lib/posixheaders/ansi_stdlib.h Brian Fox, Chet Ramey +lib/posixheaders/stdc.h Chet Ramey +lib/posixheaders/memalloc.h Chet Ramey +lib/posixheaders/filecntl.h Brian Fox, Chet Ramey +lib/readline/Makefile.in Brian Fox, Chet Ramey +lib/readline/COPYING Brian Fox, Chet Ramey +lib/readline/ChangeLog Brian Fox, Chet Ramey +lib/readline/readline.c Brian Fox, Chet Ramey +lib/readline/vi_mode.c Brian Fox, Chet Ramey +lib/readline/emacs_keymap.c Brian Fox, Chet Ramey +lib/readline/vi_keymap.c Brian Fox, Chet Ramey +lib/readline/funmap.c Brian Fox, Chet Ramey +lib/readline/keymaps.c Brian Fox, Chet Ramey +lib/readline/xmalloc.c Brian Fox, Chet Ramey +lib/readline/search.c Brian Fox, Chet Ramey +lib/readline/isearch.c Brian Fox, Chet Ramey +lib/readline/parens.c Brian Fox, Chet Ramey +lib/readline/rltty.c Brian Fox, Chet Ramey +lib/readline/complete.c Brian Fox, Chet Ramey +lib/readline/bind.c Brian Fox, Chet Ramey +lib/readline/display.c Brian Fox, Chet Ramey +lib/readline/signals.c Brian Fox, Chet Ramey +lib/readline/kill.c Brian Fox, Chet Ramey +lib/readline/undo.c Brian Fox, Chet Ramey +lib/readline/input.c Brian Fox, Chet Ramey +lib/readline/macro.c Brian Fox, Chet Ramey +lib/readline/util.c Brian Fox, Chet Ramey +lib/readline/callback.c Chet Ramey +lib/readline/readline.h Brian Fox, Chet Ramey +lib/readline/chardefs.h Brian Fox, Chet Ramey +lib/readline/keymaps.h Brian Fox, Chet Ramey +lib/readline/rldefs.h Brian Fox, Chet Ramey +lib/readline/posixstat.h Brian Fox, Chet Ramey +lib/readline/ansi_stdlib.h Brian Fox, Chet Ramey +lib/readline/memalloc.h Chet Ramey +lib/readline/rlconf.h Chet Ramey +lib/readline/rltty.h Chet Ramey +lib/readline/history.c Brian Fox, Chet Ramey +lib/readline/histexpand.c Brian Fox, Chet Ramey +lib/readline/histfile.c Brian Fox, Chet Ramey +lib/readline/histsearch.c Brian Fox, Chet Ramey +lib/readline/history.h Brian Fox, Chet Ramey +lib/readline/histlib.h Brian Fox, Chet Ramey +lib/readline/tilde.c Brian Fox, Chet Ramey +lib/readline/tilde.h Brian Fox, Chet Ramey +lib/readline/doc/texindex.c bug-texinfo at prep.ai.mit.edu, Chet Ramey +lib/readline/doc/Makefile Brian Fox, Chet Ramey +lib/readline/doc/rlman.texinfo Brian Fox, Chet Ramey +lib/readline/doc/rltech.texinfo Brian Fox, Chet Ramey +lib/readline/doc/rluser.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hist.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hstech.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hsuser.texinfo Brian Fox, Chet Ramey +lib/readline/examples/Makefile Brian Fox +lib/readline/examples/fileman.c Brian Fox +lib/readline/examples/manexamp.c Brian Fox +lib/readline/examples/histexamp.c Brian Fox, Chet Ramey +lib/readline/examples/rltest.c Brian Fox, Chet Ramey +lib/readline/examples/Inputrc Brian Fox, Chet Ramey +lib/termcap/Makefile.in David MacKenzie, Chet Ramey +lib/termcap/termcap.c David MacKenzie +lib/termcap/termcap.h David MacKenzie +lib/termcap/tparam.c David MacKenzie +lib/termcap/version.c David MacKenzie +lib/termcap/grot/termcap.info David MacKenzie +lib/termcap/grot/termcap.info-1 David MacKenzie +lib/termcap/grot/termcap.info-2 David MacKenzie +lib/termcap/grot/termcap.info-3 David MacKenzie +lib/termcap/grot/termcap.info-4 David MacKenzie +lib/termcap/grot/NEWS David MacKenzie +lib/termcap/grot/INSTALL David MacKenzie +lib/termcap/grot/ChangeLog David MacKenzie +lib/termcap/grot/texinfo.tex David MacKenzie +lib/termcap/grot/termcap.texi David MacKenzie +lib/termcap/grot/Makefile.in David MacKenzie +lib/termcap/grot/configure David MacKenzie +lib/termcap/grot/configure.in David MacKenzie +lib/termcap/grot/COPYING David MacKenzie +lib/termcap/grot/README David MacKenzie +lib/tilde/ChangeLog Brian Fox, Chet Ramey +lib/tilde/Makefile.in Brian Fox, Chet Ramey +lib/tilde/doc/tilde.texi Brian Fox, Chet Ramey +lib/tilde/doc/Makefile Brian Fox, Chet Ramey +lib/tilde/tilde.c Brian Fox, Chet Ramey +lib/tilde/tilde.h Brian Fox, Chet Ramey +lib/tilde/memalloc.h Brian Fox, Chet Ramey +CWRU/misc/open-files.c Chet Ramey +CWRU/misc/sigs.c Chet Ramey +CWRU/misc/pid.c Chet Ramey +CWRU/misc/sigstat.c Chet Ramey +CWRU/misc/bison Chet Ramey +CWRU/misc/aux-machine-desc Chet Ramey +CWRU/PLATFORMS Chet Ramey +CWRU/README Chet Ramey +CWRU/CWRU.CHANGES.051093 Chet Ramey +CWRU/POSIX.NOTES Chet Ramey +CWRU/CWRU.CHANGES.071193 Chet Ramey +CWRU/CWRU.CHANGES.090393 Chet Ramey +doc/Makefile.in Brian Fox, Chet Ramey +doc/bash.1 Chet Ramey +doc/builtins.1 Chet Ramey +doc/bash.ps Chet Ramey +doc/bash.txt Chet Ramey +doc/readline.3 Chet Ramey +doc/readline.ps Chet Ramey +doc/readline.txt Chet Ramey +doc/texinfo.tex Richard Stallman +doc/features.texi Brian Fox, Chet Ramey +doc/features.ps Brian Fox, Chet Ramey +doc/features.info Brian Fox, Chet Ramey +doc/features.dvi Brian Fox, Chet Ramey +doc/bash_builtins.1 Chet Ramey +doc/bash_builtins.ps Chet Ramey +doc/bash_builtins.txt Chet Ramey +doc/bash_builtins.readme Chet Ramey +doc/article.ms Chet Ramey +doc/FAQ Chet Ramey +support/cat-s Brian Fox, Chet Ramey +support/mksysdefs Brian Fox, Chet Ramey +support/mkversion.c Brian Fox, Chet Ramey +support/mksignames.c Brian Fox, Chet Ramey +support/getcppsyms.c Brian Fox, Chet Ramey +support/cppmagic Brian Fox, Chet Ramey +support/pagesize.sh Chet Ramey, Brian Fox +support/pagesize.c Chet Ramey, Brian Fox +support/bash.xbm Brian Fox +support/FAQ Brian Fox +support/PORTING Brian Fox +support/mklinks Brian Fox +support/fixlinks Chet Ramey +support/mkdirs Chet Ramey +support/clone-bash Chet Ramey +support/bashbug.sh Chet Ramey +support/mkmachtype Chet Ramey +support/recho.c Chet Ramey +support/config.guess Per Bothner, Chet Ramey +support/config.sub Richard Stallman, Chet Ramey +support/install.sh MIT X Consortium (X11R5) +support/endian.c Chet Ramey +support/printenv Chet Ramey +examples/precedence-tester Brian Fox, Chet Ramey +examples/functions/substr Brian Fox, Chet Ramey +examples/functions/kshenv Chet Ramey +examples/functions/autoload Chet Ramey +examples/functions/csh-compat Brian Fox, Chet Ramey +examples/functions/shcat Chet Ramey +examples/functions/substr2 Chet Ramey +examples/functions/term Chet Ramey +examples/functions/whatis Chet Ramey +examples/functions/whence Chet Ramey +examples/functions/func Chet Ramey +examples/functions/dirname Brian Fox, Noah Friedman +examples/functions/basename Brian Fox, Noah Friedman +examples/functions/exitstat Noah Friedman, Roland McGrath +examples/functions/external Noah Friedman +examples/functions/fact Brian Fox +examples/functions/manpage Tom Tromey +examples/functions/fstty Chet Ramey +examples/functions/jj.bash Chet Ramey +examples/functions/notify.bash Chet Ramey +examples/scripts/shprompt Chet Ramey +examples/scripts/adventure.sh Chet Ramey, Doug Gwyn +examples/scripts/bcsh.sh Chris Robertson, Chet Ramey +examples/startup-files/Bashrc Brian Fox +examples/startup-files/Bash_aliases Brian Fox +examples/startup-files/Bash_profile Brian Fox +examples/startup-files/bash-profile Brian Fox +examples/startup-files/bashrc Chet Ramey +examples/suncmd.termcap Brian Fox, Chet Ramey +examples/alias-conv.sh Brian Fox, Chet Ramey +tests/README Chet Ramey +tests/arith.tests Chet Ramey +tests/arith.right Chet Ramey +tests/array.tests Chet Ramey +tests/array.right Chet Ramey +tests/dollar-at.sh Chet Ramey +tests/dollar-star.sh Chet Ramey +tests/dollar.right Chet Ramey +tests/exp-tests Chet Ramey +tests/exp.right Chet Ramey +tests/glob-test Chet Ramey +tests/glob.right Chet Ramey +tests/ifs-test-1.sh Chet Ramey +tests/ifs-test-2.sh Chet Ramey +tests/ifs-test-3.sh Chet Ramey +tests/ifs.1.right Chet Ramey +tests/ifs.2.right Chet Ramey +tests/ifs.3.right Chet Ramey +tests/input-line.sh Chet Ramey +tests/input-line.sub Chet Ramey +tests/input.right Chet Ramey +tests/minus-e Chet Ramey +tests/minus-e.right Chet Ramey +tests/new-exp.tests Chet Ramey +tests/new-exp.right Chet Ramey +tests/prec.right Chet Ramey +tests/precedence Chet Ramey +tests/run-all Chet Ramey +tests/run-dollars Chet Ramey +tests/run-exp-tests Chet Ramey +tests/run-glob-test Chet Ramey +tests/run-ifs-tests Chet Ramey +tests/run-input-test Chet Ramey +tests/run-minus-e Chet Ramey +tests/run-new-exp Chet Ramey +tests/run-precedence Chet Ramey +tests/run-set-e-test Chet Ramey +tests/run-strip Chet Ramey +tests/run-varenv Chet Ramey +tests/set-e-test Chet Ramey +tests/set-e.right Chet Ramey +tests/strip.tests Chet Ramey +tests/strip.right Chet Ramey +tests/tilde-tests Chet Ramey +tests/tilde.right Chet Ramey +tests/varenv.right Chet Ramey +tests/varenv.sh Chet Ramey +tests/misc/chld-trap.sh Chet Ramey +tests/misc/dot-test-1.sh Chet Ramey +tests/misc/dot-test-1.sub Chet Ramey +tests/misc/gotest Chet Ramey +tests/misc/perf-script Chet Ramey +tests/misc/redir.t1.sh Chet Ramey +tests/misc/redir.t2.sh Chet Ramey +tests/misc/redir.t3.sh Chet Ramey +tests/misc/redir.t3.sub Chet Ramey +tests/misc/redir.t4.sh Chet Ramey +tests/misc/run.r1.sh Chet Ramey +tests/misc/run.r2.sh Chet Ramey +tests/misc/run.r3.sh Chet Ramey +tests/misc/sigint.t1.sh Chet Ramey +tests/misc/sigint.t2.sh Chet Ramey +tests/misc/sigint.t3.sh Chet Ramey +tests/misc/sigint.t4.sh Chet Ramey +tests/misc/test-minus-e.1 Chet Ramey +tests/misc/test-minus-e.2 Chet Ramey +lib/sh/Makefile.in Chet Ramey +lib/sh/clktck.c Chet Ramey +lib/sh/clock.c Chet Ramey +lib/sh/fmtullong.c Chet Ramey +lib/sh/fmtulong.c Chet Ramey +lib/sh/getcwd.c Chet Ramey, Roland McGrath +lib/sh/getenv.c Chet Ramey, Brian Fox +lib/sh/inet_aton.c Chet Ramey, Ulrich Drepper, Paul Vixie +lib/sh/itos.c Chet Ramey +lib/sh/mailstat.c Chet Ramey +lib/sh/makepath.c Chet Ramey +lib/sh/mktime.c Chet Ramey, Paul Eggert +lib/sh/netconn.c Chet Ramey +lib/sh/netopen.c Chet Ramey +lib/sh/oslib.c Chet Ramey, Brian Fox +lib/sh/pathcanon.c Chet Ramey +lib/sh/pathphys.c Chet Ramey +lib/sh/rename.c Chet Ramey +lib/sh/setlinebuf.c Chet Ramey, Brian Fox +lib/sh/shquote.c Chet Ramey +lib/sh/shtty.c Chet Ramey +lib/sh/snprintf.c Chet Ramey, Unknown +lib/sh/spell.c Chet Ramey +lib/sh/strcasecmp.c Chet Ramey, Brian Fox +lib/sh/strerror.c Chet Ramey, Brian Fox +lib/sh/strftime.c Arnold Robbins +lib/sh/strindex.c Chet Ramey +lib/sh/stringlist.c Chet Ramey +lib/sh/stringvec.c Chet Ramey +lib/sh/strpbrk.c Roland McGrath +lib/sh/strtod.c Chet Ramey, Roland McGrath +lib/sh/strtoimax.c Chet Ramey, Paul Eggert +lib/sh/strtol.c Chet Ramey, Paul Eggert +lib/sh/strtoll.c Chet Ramey, Paul Eggert +lib/sh/strtoul.c Chet Ramey, Paul Eggert +lib/sh/strtoull.c Chet Ramey, Paul Eggert +lib/sh/strtoumax.c Chet Ramey, Paul Eggert +lib/sh/strtrans.c Chet Ramey +lib/sh/times.c Chet Ramey, Brian Fox +lib/sh/timeval.c Chet Ramey +lib/sh/tmpfile.c Chet Ramey +lib/sh/vprint.c Chet Ramey, Brian Fox +lib/sh/xstrchr.c Chet Ramey, Mitsuru Chinen +lib/sh/zread.c Chet Ramey +lib/sh/zwrite.c Chet Ramey Added: haiku/vendor/bash/current/CHANGES =================================================================== --- haiku/vendor/bash/current/CHANGES 2008-02-12 00:54:04 UTC (rev 23947) +++ haiku/vendor/bash/current/CHANGES 2008-02-12 08:40:46 UTC (rev 23948) @@ -0,0 +1,3982 @@ +This document details the changes between this version, bash-2.05b-release, +and the previous version, bash-2.05b-beta2. + +1. Changes to Bash + +a. Fixed an off-by-one error in the function that translates job + specifications. + +b. Note that we're running under Emacs and disable line editing if + $EMACS == `t'. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-beta2, +and the previous version, bash-2.05b-beta1. + +1. Changes to Bash + +a. Fixed the /= and %= arithmetic operators to catch division by zero. + +b. Added putenv, setenv, unsetenv to getenv replacement for completeness. + +c. Fixed a bug that could cause the -O expand_aliases invocation option + to not take effect. + +d. Fixed a problem with process substitution that resulted in incorrect + behavior when the number of process substitutions in an individual + command approached 64. + +2. Changes to Readline + +a. Fixed a problem with backward-char-search when on a system with support + for multibyte characters when running in a locale without any multibyte + characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-beta1, +and the previous version, bash-2.05b-alpha1. + +1. Changes to Bash + +a. Fixed a problem when parsing a POSIX.2 character class name while + evaluating a bracket expression containing multibyte characters. + +b. Changed the help text for `bind' to make it clear that any command + that may be placed in ~/.inputrc is a valid argument to `bind'. + +c. Added `help' builtin entries for `((', `[[', and arithmetic for. + +d. malloc updated again: + o slightly better overflow and underflow detection by putting the + chunk size at the beginning and end of the chunk and making + sure they match in free/realloc + o partial page allocated to make things page-aligned no longer + completely wasted + o block coalescing now enabled by default + o splitting and coalescing enabled for 32-byte chunks, the most + common size requested + o fixed a problem that resulted in spurious underflow messages and + aborts + o bin sizes are precomputed and stored in an array rather than + being computed at run time + o malloc will return memory blocks back to the system if the block + being freed is at the top of the heap and of sufficient size to + make it worthwhile + o malloc/free/realloc now inline memset instead of calling the + libc function; uses Duff's device for good performance + +e. Check for getservent(); make the service name completion code dependent + on its presence. + +f. Changed the readline callback that executes a command bound to a key + sequence to not save the executed command on the history list and to + save and restore the parsing state. + +g. Changes to lib/sh/snprintf.c: fixed some bugs in the `g' and `G' + floating point format display; implemented the "'" flag character + that turns on thousands' grouping; fixed behavior on systems where + MB_CUR_MAX does not evaluate to a constant. + +h. The `unset' builtin no longer returns a failure status when asked to + unset a previously-unset variable or function. + +i. Changes to the build system to make it easier to cross-compile bash + for different systems. + +j. Added `,' to the characters that are backslash-escaped during filename + completion, to avoid problems with complete-into-braces and RCS filenames + containing commas. + +k. Some changes to the multibyte character support code to avoid many calls + to strlen(). + +l. Bash now correctly honors setting LANG to some value when LC_ALL does not + already have a value. + +m. Fixed a bug that could cause SIGSEGV when processing nested traps with + trap handlers. + +n. The `source/.' builtin now restores the positional parameters when it + returns unless they were changed using the `set' builtin during the file's + execution. + +o. Fixed a bug that caused a syntax error when a command was terminated by + EOF. + +2. New Features in Bash + +a. There is now support for placing the long help text into separate files + installed into ${datadir}/bash. Not enabled by default; can be turned + on with `--enable-separate-helpfiles' option to configure. + +b. All builtins that take operands accept a `--' pseudo-option, except + `echo'. + +c. The `echo' builtin now accepts \0xxx (zero to three octal digits following + the `0') in addition to \xxx (one to three octal digits) for SUSv3/XPG6/ + POSIX.1-2001 compliance. + +3. Changes to Readline + +a. Fixed a small problem in _rl_insert_char with multibyte characters. + +b. Fixes from IBM for line wrapping problems when using multibyte characters. + +c. Fixed a problem which caused the display to be messed up when the last + line of a multi-line prompt (possibly containing invisible characters) + was longer than the screen width. + +d. Fixed a problem with the vi-mode `r' command that ocurred on systems with + support for multibyte characters when running in a locale without any + multibyte characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-alpha1, +and the previous version, bash-2.05a-release. + +1. Changes to Bash + +a. Some changes to work around inlining differences between compilers. + +b. Added more prototypes for internal shell typedefs, to catch argument + passing errors when using pointers to functions. + +c. The `cd' builtin now fails in posix mode when a valid directory cannot be + constructed from a relative pathname argument and the $PWD using pathname + canonicalization, and the -P option has not been supplied. Previously, + the shell would attempt to use what the user typed, leading to weird + values for $PWD and discrepancies between the value of $PWD and the + actual working directory. + +d. The `cd' builtin now resets $PWD when canonicalization fails but a chdir + to the pathname passed as an argument succeeds (when not in posix mode). + +e. The `fc' builtin has been fixed, as POSIX requires, to use the closest + history position in range when given an out-of-range argument. + +f. The history file loading code was changed to allow lines to be saved in + the history list from the shell startup files. + +g. `history -s args' now works bettern in compound commands. + +h. The tilde expansion code was fixed to better recognize when it's being + invoked in an assignment context, which enables expansion after `=' + and `:'. + +i. Fixed the command name completion code so a slash is no longer appended + to a single match if there happens to be a directory with that name in + $PWD. + +j. Fixed compound array assignment to no longer perform alias expansion, to + allow reserved words as array members, and to not produce extra output + when the `-v' option had been enabled. + +k. Fixed the programmable completion code to better handle newlines in lists + of possible completions (e.g., `complete -W'). + +l. Removed the reserved words from the `bash-builtins' manual page. + +m. Parser error reporting now attempts to do a better job of identifying the + token in error rather than doing straight textual analysis. + +n. Fixes for Inf/NaN, locales, wide/multibyte characters and zero-length + arguments in the library snprintf(3) replacement. + +o. `read -e' no longer does command name completion on the first word on + the line being read. + +p. `select' now returns failure if the read of the user's selection fails. + +q. Fixed a bug that could cause a core dump when setting $PIPESTATUS. + +r. Fixes to not allocate so many job slots when the shell is running a loop + with job control enabled in a subshell of an interactive shell. + +s. Fixed a bug in the trap code that caused traps to be inherited by + command substitutions in some cases. + +t. Fixed a bug that could cause alias expansion to inappropriately expand + the word following the alias. + +u. Fixed a bug in the `kill' builtin that mishandled negative pid arguments. + +v. The parser is less lenient when parsing assignment statements where the + characters before the `=' don't comprise a valid identifier. + +w. The arithmetic expression evaluation code now honors the setting of the + `-u' option when expanding variable names. + +x. Fixed the arithmetic evaluation code to allow array subscripts to be + assigned (`let b[7]=42') and auto-incremented and auto-decremented + (e.g., b[7]++). + +y. Reimplemented the existing prompt string date and time expansions using + strftime(3), which changed the output of \@ in some locales. + +z. Fixed a bug that could cause a core dump when a special shell variable + (like RANDOM) was converted to an array with a variable assignment. + +aa. Fixed a bug that would reset the handler for a signal the user had + trapped to a function that would exit the shell when setting the exit + trap in a non-interactive shell. + +bb. Changed the execve(2) wrapper code to check whether or not a failing + command is a directory before looking at whether a `#!' interpreter + failed for some reason. + +cc. Fixed a bug in the command printing code so it no longer inserts a `;' + after a newline, which produces a syntax error when reused as input. + +dd. The code that expands $PS4 no longer inherits the `-x' flag. + +ee. The bash-specific completion functions may now take advantage of the + double-TAB and M-? features of the standard readline completion + functions. + +ff. The mail checking code no longer prints a message if the checked file's + size has not increased, even if the access time is less than the modification time. + +gg. Rewrote the variable symbol table code: there is now a stack of + contexts, each possibly including a separate symbol table; there can + be more than one temporary environment supplied to nested invocations + of `./source'; the temporary environments no longer require so much + special-case code; shell functions now handle the temporary environment + and local variables more consistently; function scope exit is faster now + that the entire symbol table does not have to be traversed to dispose of + local variables; it is now easier to push vars from the temporary + environment to the shell's variable table in posix mode; some duplicated + code has been removed. + +hh. Regularized the error message printing code; builtin_error is now called + more consistently, and common error message strings are handled by small + functions. This should make eventual message translation easier. + +ii. Error messages now include the line number in a script when the shell + is not interactive. + +jj. Array subscript expansion now takes place even when the array variable is + unset, so side effects will take place. + +kk. Fixed a bug in the SICGHLD child-reaping code so that it won't find + jobs already marked as terminated if the OS reuses pids quickly enough. + +ll. Fixed a bug that could cause a signal to not interrupt the `wait' + builtin while it was waiting for a background process to terminate. + +mm. A couple of changes to make it easier for multiple shells to share history + files using `history -n', `history -r', and `history -w'. + +nn. The `getopts' builtin always increments OPTIND to point to the next + option to be handled when an option is returned, whether it's valid + or not, as POSIX 1003.x-2001 requires. + +oo. Changed some parts of the expansion code to avoid allocating and + immediately freeing memory without using the results for anything. + +pp. The shell now keeps track of $IFS internally, updating its internal map + each time the variable is assigned a new value (or at local scope exit). + This saves thousands of hash lookups for IFS, which, while individually + cheap, add up. + +qq. Rewrote the hash table code: searching and insertion are much faster now, + and it uses a better string hashing function; augmented the function + interface to simplify other parts of the code and remove duplicated code + +rr. The shell now uses a simple, generic `object cache' for allocating and + caching words and word lists, which were the major users of + malloc/free. + +ss. Fixed the assignment statement parsing code to allow whitespace and + newlines in subscripts when performing array element assignment. + +tt. The shell now issues many fewer calls to sigprocmask and other signal + masking system calls. + +uu. Fixed the `test' and conditional command file comparison operators to + work right when one file has a non-positive timestamp and the other + does not exist. + +vv. Fixed some cases where the special characters '\001' and '\177' in the + values of variables or positional parameters caused incorrect expansion + results. + +2. Changes to Readline + +a. Fixed output of comment-begin character when listing variable values. + +b. Added some default key bindings for common escape sequences produced by + HOME and END keys. + +c. Fixed the mark handling code to be more emacs-compatible. + +d. A bug was fixed in the code that prints possible completions to keep it + from printing empty strings in certain circumstances. + +e. Change the key sequence printing code to print ESC as M\- if ESC is a + meta-prefix character -- it's easier for users to understand than \e. + +f. Fixed unstifle_history() to return values that match the documentation. + +g. Fixed the event loop (rl_event_hook) to handle the case where the input + file descriptor is invalidated. + +h. Fixed the prompt display code to work better when the application has a + custom redisplay function. + +i. Changes to make reading and writing the history file a little faster, and + to cope with huge history files without calling abort(3) from xmalloc. + +j. The vi-mode `S' and `s' commands are now undone correctly. + +3. New Features in Bash + +a. If set, TMOUT is the default timeout for the `read' builtin. + +b. `type' has two new options: `-f' suppresses shell function lookup, and + `-P' forces a $PATH search. + +c. New code to handle multibyte characters. + +d. `select' was changed to be more ksh-compatible, in that the menu is + reprinted each time through the loop only if REPLY is set to NULL. + The previous behavior is available as a compile-time option. + +e. `complete -d' and `complete -o dirnames' now force a slash to be + appended to names which are symlinks to directories. + +f. There is now a bindable edit-and-execute-command readline command, + like the vi-mode `v' command, bound to C-xC-e in emacs mode. + +g. Added support for ksh93-like [:word:] character class in pattern matching. + +h. The $'...' quoting construct now expands \cX to Control-X. + +i. A new \D{...} prompt expansion; passes the `...' to strftime and inserts + the result into the expanded prompt. + +j. The shell now performs arithmetic in the largest integer size the + machine supports (intmax_t), instead of long. + +k. If a numeric argument is supplied to one of the bash globbing completion + functions, a `*' is appended to the word before expansion is attempted. + +l. The bash globbing completion functions now allow completions to be listed + with double tabs or if `show-all-if-ambiguous' is set. + +m. New `-o nospace' option for `complete' and `compgen' builtins; suppresses + readline's appending a space to the completed word. + +n. New `here-string' redirection operator: <<< word. + +o. When displaying variables, function attributes and definitions are shown + separately, allowing them to be re-used as input (attempting to re-use + the old output would result in syntax errors). + +p. There is a new configuration option `--enable-mem-scramble', controls + bash malloc behavior of writing garbage characters into memory at + allocation and free time. + +q. The `complete' and `compgen' builtins now have a new `-s/-A service' + option to complete on names from /etc/services. + +r. `read' has a new `-u fd' option to read from a specified file descriptor. + +s. Fix the completion code so that expansion errors in a directory name + don't cause a longjmp back to the command loop. + +t. Fixed word completion inside command substitution to work a little more + intuitively. + +u. The `printf' %q format specifier now uses $'...' quoting to print the + argument if it contains non-printing characters. + +v. The `declare' and `typeset' builtins have a new `-t' option. When applied + to functions, it causes the DEBUG trap to be inherited by the named + function. Currently has no effect on variables. + +w. The DEBUG trap is now run *before* simple commands, ((...)) commands, + [[...]] conditional commands, and for ((...)) loops. + +x. The expansion of $LINENO inside a shell function is only relative to the + function start if the shell is interactive -- if the shell is running a + script, $LINENO expands to the line number in the script. This is as + POSIX-2001 requires. + +y. The bash debugger in examples/bashdb has been modified to work with the + new DEBUG trap semantics, the command set has been made more gdb-like, + and the changes to $LINENO make debugging functions work better. Code + from Gary Vaughan. + +z. New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup + and close). + +aa. There is a new `-l' invocation option, equivalent to `--login'. + +bb. The `hash' builtin has a new `-l' option to list contents in a reusable + format, and a `-d' option to remove a name from the hash table. + +4. New Features in Readline + +a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both + be bound to readline functions. Now the arrow keys may be used in vi + insert mode. + +b. When listing completions, and the number of lines displayed is more than + the screen length, readline uses an internal pager to display the results. + This is controlled by the `page-completions' variable (default on). + +c. New code to handle editing and displaying multibyte characters. + +d. The behavior introduced in bash-2.05a of deciding whether or not to + append a slash to a completed name that is a symlink to a directory has + been made optional, controlled by the `mark-symlinked-directories' + variable (default is the 2.05a behavior). + +e. The `insert-comment' command now acts as a toggle if given a numeric + argument: if the first characters on the line don't specify a + comment, insert one; if they do, delete the comment text + +f. New application-settable completion variable: + rl_completion_mark_symlink_dirs, allows an application's completion + function to temporarily override the user's preference for appending + slashes to names which are symlinks to directories. + +g. New function available to application completion functions: + rl_completion_mode, to tell how the completion function was invoked + and decide which argument to supply to rl_complete_internal (to list + completions, etc.). + +h. Readline now has an overwrite mode, toggled by the `overwrite-mode' + bindable command, which could be bound to `Insert'. + +i. New application-settable completion variable: + rl_completion_suppress_append, inhibits appending of + rl_completion_append_character to completed words. + +j. New key bindings when reading an incremental search string: ^W yanks + the currently-matched word out of the current line into the search + string; ^Y yanks the rest of the current line into the search string, + DEL or ^H deletes characters from the search string. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05a-release, +and the previous version, bash-2.05a-rc1. + +1. Changes to Bash + +a. Fixed the `printf' builtin so that the variable name supplied as an + argument to a %n conversion must be a valid shell identifier. + +b. Improved the random number generator slightly. + +c. Changes to configuration to not put -I/usr/include into $CFLAGS, since + it messes up some includes. + +d. Corrected description of POSIXLY_CORRECT in man page and info manual. + +e. Fixed a couple of cases of incorrect function prototypes that sneaked + through and caused compilation problems. + +f. A few changes to avoid potential core dumps in the programmable completion + code. + +g. Fixed a configure problem that could cause a non-existent file to show + up in LIBOBJS. + +h. Fixed a configure problem that could cause siglist.o to not be built when + required. + +i. Changes to the strtoimax and strtoumax replacement functions to work + around buggy compilers. + +j. Fixed a problem with the snprintf replacement function that could + potentially cause a core dump. + +2. Changes to Readline + +a. Fixed a locale-specific problem in the vi-mode `goto mark' command. + +b. Fixed Makefile to not put -I/usr/include into CFLAGS, since it can cause + include file problems. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05a-rc1, +and the previous version, bash-2.05a-beta1. + +1. Changes to Bash + +a. Fixed the snprintf replacement to correctly implement the `alternate form' + of the %g and %G conversions. + +b. Fixed snprintf to correctly handle the optional precision with the %g and + %G conversions. + +c. Fixed the arithmetic evaluation code to correct the values of `@' and `_' + when translating base-64 constants (they were backwards). + +d. New library functions for formatting long and long long ints. + +e. Fixed a few places where negative array subscripts could have occurred, + mostly as the result of systems using signed characters. + +f. Fixed a few places that assumed a pid_t was no wider than an int. + +g. Fixed the `maildir' mail checking code to work on systems where a + `struct stat' doesn't include an `st_blocks' member. + +h. Fixed snprintf to make `unsigned long long' conversion formats (%llu) + work better. + +i. Fixed snprintf to not print a sign when asked to do an unsigned conversion. + +j. Made configure changes to avoid compiling empty source files in lib/sh. + +k. New replacement functions (if necessary) for strtoull, strtoll, strtoimax, + strtoumax. + [... truncated: 264699 lines follow ...] From jackburton at mail.berlios.de Tue Feb 12 09:50:03 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 12 Feb 2008 09:50:03 +0100 Subject: [Haiku-commits] r23949 - haiku/vendor/bash Message-ID: <200802120850.m1C8o39D011206@sheep.berlios.de> Author: jackburton Date: 2008-02-12 09:50:02 +0100 (Tue, 12 Feb 2008) New Revision: 23949 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23949&view=rev Added: haiku/vendor/bash/2.05b/ Log: Tagging bash 2.05b Copied: haiku/vendor/bash/2.05b (from rev 23948, haiku/vendor/bash/current) From jackburton at mail.berlios.de Tue Feb 12 10:09:13 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 12 Feb 2008 10:09:13 +0100 Subject: [Haiku-commits] r23950 - in haiku/vendor/bash/current: . CWRU CWRU/misc builtins doc examples examples/bashdb examples/complete examples/functions examples/loadables examples/misc examples/obashdb examples/scripts examples/scripts.noah examples/scripts.v2 examples/startup-files examples/startup-files/apple include lib lib/glob lib/intl lib/malloc lib/readline lib/readline/doc lib/readline/examples lib/sh lib/termcap lib/tilde po support tests Message-ID: <200802120909.m1C99DEX013148@sheep.berlios.de> Author: jackburton Date: 2008-02-12 10:02:51 +0100 (Tue, 12 Feb 2008) New Revision: 23950 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23950&view=rev Added: haiku/vendor/bash/current/ABOUT-NLS haiku/vendor/bash/current/builtins/caller.def haiku/vendor/bash/current/doc/fdl.texi haiku/vendor/bash/current/doc/fdl.txt haiku/vendor/bash/current/doc/infopost.sh haiku/vendor/bash/current/doc/version.texi haiku/vendor/bash/current/examples/INDEX.html haiku/vendor/bash/current/examples/INDEX.txt haiku/vendor/bash/current/examples/bashdb/README haiku/vendor/bash/current/examples/complete/bashcc-1.0.1.tar.gz haiku/vendor/bash/current/examples/loadables/strftime.c haiku/vendor/bash/current/include/gettext.h haiku/vendor/bash/current/lib/intl/ haiku/vendor/bash/current/lib/intl/ChangeLog haiku/vendor/bash/current/lib/intl/Makefile.in haiku/vendor/bash/current/lib/intl/VERSION haiku/vendor/bash/current/lib/intl/bindtextdom.c haiku/vendor/bash/current/lib/intl/config.charset haiku/vendor/bash/current/lib/intl/dcgettext.c haiku/vendor/bash/current/lib/intl/dcigettext.c haiku/vendor/bash/current/lib/intl/dcngettext.c haiku/vendor/bash/current/lib/intl/dgettext.c haiku/vendor/bash/current/lib/intl/dngettext.c haiku/vendor/bash/current/lib/intl/eval-plural.h haiku/vendor/bash/current/lib/intl/explodename.c haiku/vendor/bash/current/lib/intl/finddomain.c haiku/vendor/bash/current/lib/intl/gettext.c haiku/vendor/bash/current/lib/intl/gettextP.h haiku/vendor/bash/current/lib/intl/gmo.h haiku/vendor/bash/current/lib/intl/hash-string.h haiku/vendor/bash/current/lib/intl/intl-compat.c haiku/vendor/bash/current/lib/intl/l10nflist.c haiku/vendor/bash/current/lib/intl/libgnuintl.h.in haiku/vendor/bash/current/lib/intl/loadinfo.h haiku/vendor/bash/current/lib/intl/loadmsgcat.c haiku/vendor/bash/current/lib/intl/localcharset.c haiku/vendor/bash/current/lib/intl/localcharset.h haiku/vendor/bash/current/lib/intl/locale.alias haiku/vendor/bash/current/lib/intl/localealias.c haiku/vendor/bash/current/lib/intl/localename.c haiku/vendor/bash/current/lib/intl/log.c haiku/vendor/bash/current/lib/intl/ngettext.c haiku/vendor/bash/current/lib/intl/os2compat.c haiku/vendor/bash/current/lib/intl/os2compat.h haiku/vendor/bash/current/lib/intl/osdep.c haiku/vendor/bash/current/lib/intl/plural-exp.c haiku/vendor/bash/current/lib/intl/plural-exp.h haiku/vendor/bash/current/lib/intl/plural.c haiku/vendor/bash/current/lib/intl/plural.y haiku/vendor/bash/current/lib/intl/ref-add.sin haiku/vendor/bash/current/lib/intl/ref-del.sin haiku/vendor/bash/current/lib/intl/relocatable.c haiku/vendor/bash/current/lib/intl/relocatable.h haiku/vendor/bash/current/lib/intl/textdomain.c haiku/vendor/bash/current/lib/readline/doc/fdl.texi haiku/vendor/bash/current/lib/readline/doc/history.texi haiku/vendor/bash/current/lib/readline/doc/hstech.texi haiku/vendor/bash/current/lib/readline/doc/hsuser.texi haiku/vendor/bash/current/lib/readline/doc/rlman.texi haiku/vendor/bash/current/lib/readline/doc/rltech.texi haiku/vendor/bash/current/lib/readline/doc/rluser.texi haiku/vendor/bash/current/lib/readline/doc/rluserman.texi haiku/vendor/bash/current/lib/readline/doc/version.texi haiku/vendor/bash/current/lib/sh/eaccess.c haiku/vendor/bash/current/lib/sh/shmatch.c haiku/vendor/bash/current/lib/sh/strnlen.c haiku/vendor/bash/current/lib/sh/strstr.c haiku/vendor/bash/current/lib/sh/wcsdup.c haiku/vendor/bash/current/lib/sh/winsize.c haiku/vendor/bash/current/pathnames.h.in haiku/vendor/bash/current/po/ haiku/vendor/bash/current/po/LINGUAS haiku/vendor/bash/current/po/Makefile.in.in haiku/vendor/bash/current/po/Makevars haiku/vendor/bash/current/po/POTFILES.in haiku/vendor/bash/current/po/Rules-builtins haiku/vendor/bash/current/po/Rules-quot haiku/vendor/bash/current/po/bash.pot haiku/vendor/bash/current/po/boldquot.sed haiku/vendor/bash/current/po/en at boldquot.gmo haiku/vendor/bash/current/po/en at boldquot.header haiku/vendor/bash/current/po/en at boldquot.po haiku/vendor/bash/current/po/en at quot.gmo haiku/vendor/bash/current/po/en at quot.header haiku/vendor/bash/current/po/en at quot.po haiku/vendor/bash/current/po/insert-header.sin haiku/vendor/bash/current/po/quot.sed haiku/vendor/bash/current/po/remove-potcdate.sin haiku/vendor/bash/current/po/ru.po haiku/vendor/bash/current/support/config.rpath haiku/vendor/bash/current/support/mkinstalldirs haiku/vendor/bash/current/support/signames.c haiku/vendor/bash/current/tests/COPYRIGHT haiku/vendor/bash/current/tests/alias.right haiku/vendor/bash/current/tests/alias.tests haiku/vendor/bash/current/tests/appendop.right haiku/vendor/bash/current/tests/appendop.tests haiku/vendor/bash/current/tests/arith1.sub haiku/vendor/bash/current/tests/arith2.sub haiku/vendor/bash/current/tests/array1.sub haiku/vendor/bash/current/tests/array2.sub haiku/vendor/bash/current/tests/array3.sub haiku/vendor/bash/current/tests/array4.sub haiku/vendor/bash/current/tests/braces.tests haiku/vendor/bash/current/tests/dbg-support.right haiku/vendor/bash/current/tests/dbg-support.sub haiku/vendor/bash/current/tests/dbg-support.tests haiku/vendor/bash/current/tests/dbg-support2.right haiku/vendor/bash/current/tests/dbg-support2.tests haiku/vendor/bash/current/tests/dollar-at1.sub haiku/vendor/bash/current/tests/dollar-at2.sub haiku/vendor/bash/current/tests/dollar-star1.sub haiku/vendor/bash/current/tests/dollar-star2.sub haiku/vendor/bash/current/tests/exec7.sub haiku/vendor/bash/current/tests/extglob1.sub haiku/vendor/bash/current/tests/extglob3.right haiku/vendor/bash/current/tests/extglob3.tests haiku/vendor/bash/current/tests/ifs-posix.right haiku/vendor/bash/current/tests/ifs-posix.tests haiku/vendor/bash/current/tests/intl.right haiku/vendor/bash/current/tests/intl.tests haiku/vendor/bash/current/tests/iquote.right haiku/vendor/bash/current/tests/iquote.tests haiku/vendor/bash/current/tests/jobs4.sub haiku/vendor/bash/current/tests/new-exp4.sub haiku/vendor/bash/current/tests/new-exp5.sub haiku/vendor/bash/current/tests/new-exp6.sub haiku/vendor/bash/current/tests/nquote4.right haiku/vendor/bash/current/tests/nquote4.tests haiku/vendor/bash/current/tests/read5.sub haiku/vendor/bash/current/tests/redir6.sub haiku/vendor/bash/current/tests/redir7.sub haiku/vendor/bash/current/tests/run-alias haiku/vendor/bash/current/tests/run-appendop haiku/vendor/bash/current/tests/run-dbg-support haiku/vendor/bash/current/tests/run-dbg-support2 haiku/vendor/bash/current/tests/run-extglob3 haiku/vendor/bash/current/tests/run-ifs-posix haiku/vendor/bash/current/tests/run-intl haiku/vendor/bash/current/tests/run-iquote haiku/vendor/bash/current/tests/run-nquote4 haiku/vendor/bash/current/tests/run-set-x haiku/vendor/bash/current/tests/run-tilde2 haiku/vendor/bash/current/tests/set-x.right haiku/vendor/bash/current/tests/set-x.tests haiku/vendor/bash/current/tests/tilde.tests haiku/vendor/bash/current/tests/tilde2.right haiku/vendor/bash/current/tests/tilde2.tests Modified: haiku/vendor/bash/current/AUTHORS haiku/vendor/bash/current/CHANGES haiku/vendor/bash/current/COMPAT haiku/vendor/bash/current/CWRU/changelog haiku/vendor/bash/current/CWRU/misc/open-files.c haiku/vendor/bash/current/INSTALL haiku/vendor/bash/current/MANIFEST haiku/vendor/bash/current/Makefile.in haiku/vendor/bash/current/NEWS haiku/vendor/bash/current/NOTES haiku/vendor/bash/current/POSIX haiku/vendor/bash/current/RBASH haiku/vendor/bash/current/README haiku/vendor/bash/current/Y2K haiku/vendor/bash/current/aclocal.m4 haiku/vendor/bash/current/array.c haiku/vendor/bash/current/array.h haiku/vendor/bash/current/arrayfunc.c haiku/vendor/bash/current/arrayfunc.h haiku/vendor/bash/current/bashhist.c haiku/vendor/bash/current/bashhist.h haiku/vendor/bash/current/bashintl.h haiku/vendor/bash/current/bashjmp.h haiku/vendor/bash/current/bashline.c haiku/vendor/bash/current/bashline.h haiku/vendor/bash/current/braces.c haiku/vendor/bash/current/builtins.h haiku/vendor/bash/current/builtins/Makefile.in haiku/vendor/bash/current/builtins/alias.def haiku/vendor/bash/current/builtins/bind.def haiku/vendor/bash/current/builtins/break.def haiku/vendor/bash/current/builtins/builtin.def haiku/vendor/bash/current/builtins/cd.def haiku/vendor/bash/current/builtins/command.def haiku/vendor/bash/current/builtins/common.c haiku/vendor/bash/current/builtins/common.h haiku/vendor/bash/current/builtins/complete.def haiku/vendor/bash/current/builtins/declare.def haiku/vendor/bash/current/builtins/echo.def haiku/vendor/bash/current/builtins/enable.def haiku/vendor/bash/current/builtins/evalfile.c haiku/vendor/bash/current/builtins/evalstring.c haiku/vendor/bash/current/builtins/exec.def haiku/vendor/bash/current/builtins/exit.def haiku/vendor/bash/current/builtins/fc.def haiku/vendor/bash/current/builtins/fg_bg.def haiku/vendor/bash/current/builtins/getopt.c haiku/vendor/bash/current/builtins/getopts.def haiku/vendor/bash/current/builtins/hash.def haiku/vendor/bash/current/builtins/help.def haiku/vendor/bash/current/builtins/history.def haiku/vendor/bash/current/builtins/jobs.def haiku/vendor/bash/current/builtins/kill.def haiku/vendor/bash/current/builtins/let.def haiku/vendor/bash/current/builtins/mkbuiltins.c haiku/vendor/bash/current/builtins/printf.def haiku/vendor/bash/current/builtins/psize.c haiku/vendor/bash/current/builtins/pushd.def haiku/vendor/bash/current/builtins/read.def haiku/vendor/bash/current/builtins/reserved.def haiku/vendor/bash/current/builtins/return.def haiku/vendor/bash/current/builtins/set.def haiku/vendor/bash/current/builtins/setattr.def haiku/vendor/bash/current/builtins/shift.def haiku/vendor/bash/current/builtins/shopt.def haiku/vendor/bash/current/builtins/source.def haiku/vendor/bash/current/builtins/suspend.def haiku/vendor/bash/current/builtins/trap.def haiku/vendor/bash/current/builtins/type.def haiku/vendor/bash/current/builtins/ulimit.def haiku/vendor/bash/current/builtins/umask.def haiku/vendor/bash/current/builtins/wait.def haiku/vendor/bash/current/command.h haiku/vendor/bash/current/config-bot.h haiku/vendor/bash/current/config-top.h haiku/vendor/bash/current/config.h.in haiku/vendor/bash/current/configure haiku/vendor/bash/current/configure.in haiku/vendor/bash/current/conftypes.h haiku/vendor/bash/current/copy_cmd.c haiku/vendor/bash/current/dispose_cmd.c haiku/vendor/bash/current/dispose_cmd.h haiku/vendor/bash/current/doc/FAQ haiku/vendor/bash/current/doc/Makefile.in haiku/vendor/bash/current/doc/bash.1 haiku/vendor/bash/current/doc/bashref.info haiku/vendor/bash/current/doc/bashref.texi haiku/vendor/bash/current/doc/builtins.1 haiku/vendor/bash/current/doc/rbash.1 haiku/vendor/bash/current/doc/texinfo.tex haiku/vendor/bash/current/error.c haiku/vendor/bash/current/eval.c haiku/vendor/bash/current/examples/bashdb/bashdb haiku/vendor/bash/current/examples/functions/coproc.bash haiku/vendor/bash/current/examples/functions/csh-compat haiku/vendor/bash/current/examples/functions/exitstat haiku/vendor/bash/current/examples/functions/getoptx.bash haiku/vendor/bash/current/examples/functions/kshenv haiku/vendor/bash/current/examples/functions/manpage haiku/vendor/bash/current/examples/functions/recurse haiku/vendor/bash/current/examples/functions/substr haiku/vendor/bash/current/examples/functions/substr2 haiku/vendor/bash/current/examples/functions/xalias.bash haiku/vendor/bash/current/examples/functions/xfind.bash haiku/vendor/bash/current/examples/loadables/Makefile.in haiku/vendor/bash/current/examples/loadables/README haiku/vendor/bash/current/examples/loadables/finfo.c haiku/vendor/bash/current/examples/loadables/getconf.c haiku/vendor/bash/current/examples/misc/aliasconv.bash haiku/vendor/bash/current/examples/misc/aliasconv.sh haiku/vendor/bash/current/examples/misc/cshtobash haiku/vendor/bash/current/examples/obashdb/README haiku/vendor/bash/current/examples/obashdb/bashdb.fns haiku/vendor/bash/current/examples/scripts.noah/README haiku/vendor/bash/current/examples/scripts.noah/number.bash haiku/vendor/bash/current/examples/scripts.noah/string.bash haiku/vendor/bash/current/examples/scripts.v2/README haiku/vendor/bash/current/examples/scripts.v2/cdhist.bash haiku/vendor/bash/current/examples/scripts.v2/fman haiku/vendor/bash/current/examples/scripts.v2/frcp haiku/vendor/bash/current/examples/scripts.v2/repeat haiku/vendor/bash/current/examples/scripts.v2/vtree haiku/vendor/bash/current/examples/scripts/bcsh.sh haiku/vendor/bash/current/examples/scripts/fixfiles.bash haiku/vendor/bash/current/examples/scripts/line-input.bash haiku/vendor/bash/current/examples/startup-files/README haiku/vendor/bash/current/examples/startup-files/apple/README haiku/vendor/bash/current/execute_cmd.c haiku/vendor/bash/current/expr.c haiku/vendor/bash/current/externs.h haiku/vendor/bash/current/findcmd.c haiku/vendor/bash/current/flags.c haiku/vendor/bash/current/flags.h haiku/vendor/bash/current/general.c haiku/vendor/bash/current/general.h haiku/vendor/bash/current/include/posixdir.h haiku/vendor/bash/current/include/shmbutil.h haiku/vendor/bash/current/include/stdc.h haiku/vendor/bash/current/input.c haiku/vendor/bash/current/input.h haiku/vendor/bash/current/jobs.c haiku/vendor/bash/current/jobs.h haiku/vendor/bash/current/lib/glob/Makefile.in haiku/vendor/bash/current/lib/glob/glob.c haiku/vendor/bash/current/lib/glob/glob_loop.c haiku/vendor/bash/current/lib/glob/sm_loop.c haiku/vendor/bash/current/lib/glob/smatch.c haiku/vendor/bash/current/lib/glob/strmatch.c haiku/vendor/bash/current/lib/glob/strmatch.h haiku/vendor/bash/current/lib/glob/xmbsrtowcs.c haiku/vendor/bash/current/lib/malloc/Makefile.in haiku/vendor/bash/current/lib/malloc/getpagesize.h haiku/vendor/bash/current/lib/malloc/imalloc.h haiku/vendor/bash/current/lib/malloc/malloc.c haiku/vendor/bash/current/lib/malloc/mstats.h haiku/vendor/bash/current/lib/malloc/shmalloc.h haiku/vendor/bash/current/lib/malloc/stats.c haiku/vendor/bash/current/lib/malloc/stub.c haiku/vendor/bash/current/lib/malloc/table.c haiku/vendor/bash/current/lib/malloc/table.h haiku/vendor/bash/current/lib/malloc/trace.c haiku/vendor/bash/current/lib/malloc/watch.c haiku/vendor/bash/current/lib/malloc/watch.h haiku/vendor/bash/current/lib/malloc/xleaktrace haiku/vendor/bash/current/lib/malloc/xmalloc.c haiku/vendor/bash/current/lib/readline/Makefile.in haiku/vendor/bash/current/lib/readline/bind.c haiku/vendor/bash/current/lib/readline/callback.c haiku/vendor/bash/current/lib/readline/chardefs.h haiku/vendor/bash/current/lib/readline/complete.c haiku/vendor/bash/current/lib/readline/display.c haiku/vendor/bash/current/lib/readline/doc/Makefile haiku/vendor/bash/current/lib/readline/examples/excallback.c haiku/vendor/bash/current/lib/readline/examples/histexamp.c haiku/vendor/bash/current/lib/readline/examples/rl.c haiku/vendor/bash/current/lib/readline/examples/rlcat.c haiku/vendor/bash/current/lib/readline/examples/rltest.c haiku/vendor/bash/current/lib/readline/funmap.c haiku/vendor/bash/current/lib/readline/histexpand.c haiku/vendor/bash/current/lib/readline/histfile.c haiku/vendor/bash/current/lib/readline/history.c haiku/vendor/bash/current/lib/readline/history.h haiku/vendor/bash/current/lib/readline/histsearch.c haiku/vendor/bash/current/lib/readline/input.c haiku/vendor/bash/current/lib/readline/isearch.c haiku/vendor/bash/current/lib/readline/keymaps.c haiku/vendor/bash/current/lib/readline/kill.c haiku/vendor/bash/current/lib/readline/macro.c haiku/vendor/bash/current/lib/readline/mbutil.c haiku/vendor/bash/current/lib/readline/misc.c haiku/vendor/bash/current/lib/readline/nls.c haiku/vendor/bash/current/lib/readline/parens.c haiku/vendor/bash/current/lib/readline/posixdir.h haiku/vendor/bash/current/lib/readline/readline.c haiku/vendor/bash/current/lib/readline/readline.h haiku/vendor/bash/current/lib/readline/rlconf.h haiku/vendor/bash/current/lib/readline/rldefs.h haiku/vendor/bash/current/lib/readline/rlmbutil.h haiku/vendor/bash/current/lib/readline/rlprivate.h haiku/vendor/bash/current/lib/readline/rlstdc.h haiku/vendor/bash/current/lib/readline/rltty.c haiku/vendor/bash/current/lib/readline/rltty.h haiku/vendor/bash/current/lib/readline/rltypedefs.h haiku/vendor/bash/current/lib/readline/savestring.c haiku/vendor/bash/current/lib/readline/search.c haiku/vendor/bash/current/lib/readline/shell.c haiku/vendor/bash/current/lib/readline/signals.c haiku/vendor/bash/current/lib/readline/terminal.c haiku/vendor/bash/current/lib/readline/text.c haiku/vendor/bash/current/lib/readline/tilde.c haiku/vendor/bash/current/lib/readline/tilde.h haiku/vendor/bash/current/lib/readline/undo.c haiku/vendor/bash/current/lib/readline/util.c haiku/vendor/bash/current/lib/readline/vi_keymap.c haiku/vendor/bash/current/lib/readline/vi_mode.c haiku/vendor/bash/current/lib/sh/Makefile.in haiku/vendor/bash/current/lib/sh/fmtulong.c haiku/vendor/bash/current/lib/sh/getcwd.c haiku/vendor/bash/current/lib/sh/getenv.c haiku/vendor/bash/current/lib/sh/mailstat.c haiku/vendor/bash/current/lib/sh/netconn.c haiku/vendor/bash/current/lib/sh/netopen.c haiku/vendor/bash/current/lib/sh/pathcanon.c haiku/vendor/bash/current/lib/sh/pathphys.c haiku/vendor/bash/current/lib/sh/shquote.c haiku/vendor/bash/current/lib/sh/snprintf.c haiku/vendor/bash/current/lib/sh/strftime.c haiku/vendor/bash/current/lib/sh/strtoimax.c haiku/vendor/bash/current/lib/sh/strtoumax.c haiku/vendor/bash/current/lib/sh/strtrans.c haiku/vendor/bash/current/lib/sh/tmpfile.c haiku/vendor/bash/current/lib/sh/zread.c haiku/vendor/bash/current/lib/termcap/Makefile.in haiku/vendor/bash/current/lib/termcap/termcap.c haiku/vendor/bash/current/lib/termcap/tparam.c haiku/vendor/bash/current/lib/tilde/Makefile.in haiku/vendor/bash/current/lib/tilde/tilde.c haiku/vendor/bash/current/lib/tilde/tilde.h haiku/vendor/bash/current/locale.c haiku/vendor/bash/current/mailcheck.c haiku/vendor/bash/current/make_cmd.c haiku/vendor/bash/current/make_cmd.h haiku/vendor/bash/current/mksyntax.c haiku/vendor/bash/current/nojobs.c haiku/vendor/bash/current/parse.y haiku/vendor/bash/current/parser-built haiku/vendor/bash/current/patchlevel.h haiku/vendor/bash/current/pathexp.h haiku/vendor/bash/current/pcomplete.c haiku/vendor/bash/current/pcomplete.h haiku/vendor/bash/current/pcomplib.c haiku/vendor/bash/current/print_cmd.c haiku/vendor/bash/current/quit.h haiku/vendor/bash/current/redir.c haiku/vendor/bash/current/redir.h haiku/vendor/bash/current/shell.c haiku/vendor/bash/current/shell.h haiku/vendor/bash/current/sig.c haiku/vendor/bash/current/sig.h haiku/vendor/bash/current/subst.c haiku/vendor/bash/current/subst.h haiku/vendor/bash/current/support/Makefile.in haiku/vendor/bash/current/support/bash.xbm haiku/vendor/bash/current/support/bashbug.sh haiku/vendor/bash/current/support/config.guess haiku/vendor/bash/current/support/config.sub haiku/vendor/bash/current/support/man2html.c haiku/vendor/bash/current/support/mksignames.c haiku/vendor/bash/current/support/mkversion.sh haiku/vendor/bash/current/support/printenv.c haiku/vendor/bash/current/support/recho.c haiku/vendor/bash/current/support/shobj-conf haiku/vendor/bash/current/support/texi2dvi haiku/vendor/bash/current/support/xenix-link.sh haiku/vendor/bash/current/support/zecho.c haiku/vendor/bash/current/syntax.h haiku/vendor/bash/current/test.c haiku/vendor/bash/current/test.h haiku/vendor/bash/current/tests/README haiku/vendor/bash/current/tests/arith-for.right haiku/vendor/bash/current/tests/arith.right haiku/vendor/bash/current/tests/arith.tests haiku/vendor/bash/current/tests/array.right haiku/vendor/bash/current/tests/array.tests haiku/vendor/bash/current/tests/braces.right haiku/vendor/bash/current/tests/builtins.right haiku/vendor/bash/current/tests/builtins.tests haiku/vendor/bash/current/tests/cond.right haiku/vendor/bash/current/tests/cond.tests haiku/vendor/bash/current/tests/cprint.right haiku/vendor/bash/current/tests/dollar-at-star haiku/vendor/bash/current/tests/dollar.right haiku/vendor/bash/current/tests/errors.right haiku/vendor/bash/current/tests/exec.right haiku/vendor/bash/current/tests/execscript haiku/vendor/bash/current/tests/exp-tests haiku/vendor/bash/current/tests/exp.right haiku/vendor/bash/current/tests/extglob.right haiku/vendor/bash/current/tests/extglob.tests haiku/vendor/bash/current/tests/func.right haiku/vendor/bash/current/tests/func.tests haiku/vendor/bash/current/tests/glob-test haiku/vendor/bash/current/tests/glob.right haiku/vendor/bash/current/tests/heredoc.right haiku/vendor/bash/current/tests/herestr.right haiku/vendor/bash/current/tests/herestr.tests haiku/vendor/bash/current/tests/histexp.right haiku/vendor/bash/current/tests/histexp.tests haiku/vendor/bash/current/tests/history.right haiku/vendor/bash/current/tests/history.tests haiku/vendor/bash/current/tests/jobs.right haiku/vendor/bash/current/tests/jobs.tests haiku/vendor/bash/current/tests/more-exp.right haiku/vendor/bash/current/tests/more-exp.tests haiku/vendor/bash/current/tests/new-exp.right haiku/vendor/bash/current/tests/new-exp.tests haiku/vendor/bash/current/tests/nquote.right haiku/vendor/bash/current/tests/nquote.tests haiku/vendor/bash/current/tests/printf.right haiku/vendor/bash/current/tests/printf.tests haiku/vendor/bash/current/tests/quote.right haiku/vendor/bash/current/tests/quote.tests haiku/vendor/bash/current/tests/read.right haiku/vendor/bash/current/tests/read.tests haiku/vendor/bash/current/tests/read2.sub haiku/vendor/bash/current/tests/redir.right haiku/vendor/bash/current/tests/redir.tests haiku/vendor/bash/current/tests/rhs-exp.right haiku/vendor/bash/current/tests/rhs-exp.tests haiku/vendor/bash/current/tests/run-braces haiku/vendor/bash/current/tests/run-execscript haiku/vendor/bash/current/tests/run-glob-test haiku/vendor/bash/current/tests/run-jobs haiku/vendor/bash/current/tests/run-minimal haiku/vendor/bash/current/tests/run-read haiku/vendor/bash/current/tests/run-test haiku/vendor/bash/current/tests/run-tilde haiku/vendor/bash/current/tests/shopt.right haiku/vendor/bash/current/tests/test.tests haiku/vendor/bash/current/tests/tilde.right haiku/vendor/bash/current/tests/trap.right haiku/vendor/bash/current/tests/trap.tests haiku/vendor/bash/current/tests/type.right haiku/vendor/bash/current/tests/type.tests haiku/vendor/bash/current/tests/varenv.right haiku/vendor/bash/current/tests/varenv.sh haiku/vendor/bash/current/trap.c haiku/vendor/bash/current/trap.h haiku/vendor/bash/current/unwind_prot.c haiku/vendor/bash/current/variables.c haiku/vendor/bash/current/variables.h haiku/vendor/bash/current/version.c haiku/vendor/bash/current/xmalloc.c haiku/vendor/bash/current/y.tab.c haiku/vendor/bash/current/y.tab.h Log: Updating vendor branch bash to 3.2 Added: haiku/vendor/bash/current/ABOUT-NLS =================================================================== --- haiku/vendor/bash/current/ABOUT-NLS 2008-02-12 08:50:02 UTC (rev 23949) +++ haiku/vendor/bash/current/ABOUT-NLS 2008-02-12 09:02:51 UTC (rev 23950) @@ -0,0 +1,625 @@ +Notes on the Free Translation Project +************************************* + + Free software is going international! The Free Translation Project +is a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +Quick configuration advice +========================== + + If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias, message inheritance, automatic +charset conversion or plural form handling) as the implementation here. +It is also not possible to offer this additional functionality on top +of a `catgets' implementation. Future versions of GNU `gettext' will +very likely convey even more functionality. So it might be a good idea +to change to GNU `gettext' as soon as possible. + + So you need _not_ provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + + Some packages are "localizable" when properly installed; the +programs they contain can be made to speak your own native language. +Most such packages use GNU `gettext'. Other packages have their own +ways to internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. If not, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is _not_ required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --disable-nls + +will respectively bypass any pre-existing `gettext' to use the +internationalizing routines provided within this package, or else, +_totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + The configuration process will not test for the `catgets' function +and therefore it will not be used. The reason is that even an +emulation of `gettext' on top of `catgets' could not provide all the +extensions of the GNU `gettext' library. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + + As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, +and `CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your country by running the command +`locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +Translating Teams +================= + + For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" +area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request at li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation at iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + + Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of May 2003. +The matrix shows, in regard of each package, for which languages PO +files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files am az be bg ca cs da de el en en_GB eo es + +-------------------------------------------+ + a2ps | [] [] [] [] | + aegis | () | + anubis | | + ap-utils | | + bash | [] [] [] | + batchelor | | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] | + bluez-pin | [] [] | + clisp | | + clisp | [] [] [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + darkstat | () [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + error | [] [] [] [] [] | + fetchmail | [] () [] [] [] [] | + fileutils | [] [] [] | + findutils | [] [] [] [] [] [] | + flex | [] [] [] [] | + gas | [] | + gawk | [] [] [] [] | + gcal | [] | + gcc | [] [] | + gettext | [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] | + gimp-print | [] [] [] [] [] | + gliv | | + glunarclock | [] [] [] | + gnucash | () [] | + gnucash-glossary | [] () [] | + gnupg | [] () [] [] [] [] | + gpe-calendar | [] | + gpe-conf | [] | + gpe-contacts | [] | + gpe-edit | | + gpe-login | [] | + gpe-ownerinfo | [] | + gpe-sketchbook | [] | + gpe-timesheet | | + gpe-today | [] | + gpe-todo | [] | + gphoto2 | [] [] [] [] | + gprof | [] [] | + gpsdrive | () () () | + grep | [] [] [] [] [] | + gretl | [] | + hello | [] [] [] [] [] [] | + id-utils | [] [] | + indent | [] [] [] [] | + jpilot | [] [] [] [] | + jwhois | [] | + kbd | [] [] [] [] [] | + ld | [] [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] | + libiconv | [] [] [] [] [] | + lifelines | [] () | + lilypond | [] | + lingoteach | | + lingoteach_lessons | () () | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] | + man-db | [] () [] [] () | + mysecretdiary | [] [] [] | + nano | [] () [] [] [] | + nano_1_0 | [] () [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] [] | + ptx | [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] [] [] [] | + screem | | + sed | [] [] [] [] [] | + sh-utils | [] [] [] | + sharutils | [] [] [] [] [] [] | + sketch | [] () [] | + soundtracker | [] [] [] | + sp | [] | + tar | [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] | + tin | () () | + util-linux | [] [] [] [] [] | + vorbis-tools | [] [] [] | + wastesedge | () | + wdiff | [] [] [] [] | + wget | [] [] [] [] [] [] [] | + xchat | [] [] [] | + xpad | | + +-------------------------------------------+ + am az be bg ca cs da de el en en_GB eo es + 0 1 4 2 31 17 54 60 14 1 4 12 56 + + et fa fi fr ga gl he hr hu id it ja ko + +----------------------------------------+ + a2ps | [] [] [] () () | + aegis | | + anubis | [] | + ap-utils | [] | + bash | [] [] | + batchelor | [] | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] [] | + bluez-pin | [] [] [] [] | + clisp | | + clisp | [] | + coreutils | [] [] [] [] | + cpio | [] [] [] [] | + darkstat | () [] [] [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] [] [] | + fetchmail | [] | + fileutils | [] [] [] [] [] | + findutils | [] [] [] [] [] [] [] [] [] [] [] | + flex | [] [] | + gas | [] | + gawk | [] [] | + gcal | [] | + gcc | [] | + gettext | [] [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] | + gimp-print | [] [] | + gliv | () | + glunarclock | [] [] [] [] | + gnucash | [] | + gnucash-glossary | [] | + gnupg | [] [] [] [] [] [] [] | + gpe-calendar | [] | + gpe-conf | | + gpe-contacts | [] | + gpe-edit | [] [] | + gpe-login | [] | + gpe-ownerinfo | [] [] [] | + gpe-sketchbook | [] | + gpe-timesheet | [] [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] | + gprof | [] [] | + gpsdrive | () [] () () | + grep | [] [] [] [] [] [] [] [] [] [] [] | + gretl | [] | + hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] [] [] [] [] [] | + jpilot | [] () | + jwhois | [] [] [] [] | + kbd | [] | + ld | [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] [] [] | + libiconv | [] [] [] [] [] [] [] [] | + lifelines | () | + lilypond | [] | + lingoteach | [] [] | + lingoteach_lessons | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] [] [] [] [] | + man-db | [] () () | + mysecretdiary | [] [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] [] [] [] | + screem | | + sed | [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] | + sharutils | [] [] [] [] [] | + sketch | [] | + soundtracker | [] [] [] | + sp | [] () | + tar | [] [] [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] [] | + tin | [] () | + util-linux | [] [] [] [] () [] | + vorbis-tools | [] | + wastesedge | () | + wdiff | [] [] [] [] [] | + wget | [] [] [] [] [] [] [] [] | + xchat | [] [] [] | + xpad | | + +----------------------------------------+ + et fa fi fr ga gl he hr hu id it ja ko + 20 1 15 73 14 24 8 10 30 31 19 31 9 + + lg lt lv ms nb nl nn no pl pt pt_BR ro + +----------------------------------------+ + a2ps | [] [] () () () [] [] | + aegis | () | + anubis | [] [] | + ap-utils | () | + bash | [] | + batchelor | | + bfd | | + binutils | | + bison | [] [] [] [] | + bluez-pin | [] | + clisp | | + clisp | [] | + coreutils | [] | + cpio | [] [] [] | + darkstat | [] [] [] [] | + diffutils | [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] | + fetchmail | () () | + fileutils | [] | + findutils | [] [] [] [] | + flex | [] | + gas | | + gawk | [] | + gcal | | + gcc | | + gettext | [] | + gettext-runtime | [] | + gettext-tools | | + gimp-print | [] | + gliv | [] | + glunarclock | [] | + gnucash | | + gnucash-glossary | [] [] | + gnupg | | + gpe-calendar | [] [] | + gpe-conf | [] [] | + gpe-contacts | [] | + gpe-edit | [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] | + gpe-sketchbook | [] [] | + gpe-timesheet | [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | | + gprof | [] | + gpsdrive | () () () | + grep | [] [] [] [] | + gretl | | + hello | [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] | + jpilot | () () | + jwhois | [] [] [] | + kbd | | + ld | | + libc | [] [] [] [] | + libgpewidget | [] [] | + libiconv | [] [] | + lifelines | | + lilypond | [] | + lingoteach | | + lingoteach_lessons | | + lynx | [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] | + man-db | [] | + mysecretdiary | [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] [] [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] | + screem | | + sed | [] [] | + sh-utils | [] | + sharutils | [] | + sketch | [] | + soundtracker | | + sp | | + tar | [] [] [] [] [] [] | + texinfo | [] | + textutils | [] | + tin | | + util-linux | [] [] | + vorbis-tools | [] [] | + wastesedge | | + wdiff | [] [] [] [] | + wget | [] [] [] | + xchat | [] [] | + xpad | [] | + +----------------------------------------+ + lg lt lv ms nb nl nn no pl pt pt_BR ro + 0 0 2 11 7 26 3 4 18 15 34 34 + + ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + +-------------------------------------------+ + a2ps | [] [] [] [] [] | 16 + aegis | () | 0 + anubis | [] [] | 5 + ap-utils | () | 1 + bash | [] | 7 + batchelor | | 1 + bfd | [] [] [] | 7 + binutils | [] [] [] | 7 + bison | [] [] | 13 + bluez-pin | | 7 + clisp | | 0 + clisp | | 5 + coreutils | [] [] [] [] [] | 14 + cpio | [] [] [] | 13 + darkstat | [] () () | 9 + diffutils | [] [] [] [] | 21 + e2fsprogs | [] | 3 + enscript | [] [] [] | 11 + error | [] [] [] | 14 + fetchmail | [] | 7 + fileutils | [] [] [] [] [] [] | 15 + findutils | [] [] [] [] [] [] | 27 + flex | [] [] [] | 10 + gas | [] | 3 + gawk | [] [] | 9 + gcal | [] [] | 4 + gcc | [] | 4 + gettext | [] [] [] [] [] [] | 15 + gettext-runtime | [] [] [] [] [] [] | 16 + gettext-tools | [] [] | 5 + gimp-print | [] [] | 10 + gliv | | 1 + glunarclock | [] [] [] | 11 + gnucash | [] [] | 4 + gnucash-glossary | [] [] [] | 8 + gnupg | [] [] [] [] | 16 + gpe-calendar | [] | 5 + gpe-conf | | 3 + gpe-contacts | [] | 4 + gpe-edit | [] | 5 + gpe-login | [] | 5 + gpe-ownerinfo | [] | 7 + gpe-sketchbook | [] | 5 + gpe-timesheet | [] | 6 + gpe-today | [] | 6 + gpe-todo | [] | 6 + gphoto2 | [] [] | 9 + gprof | [] [] | 7 + gpsdrive | [] [] | 3 + grep | [] [] [] [] | 24 + gretl | | 2 + hello | [] [] [] [] [] | 33 + id-utils | [] [] [] | 11 + indent | [] [] [] [] | 19 + jpilot | [] [] [] [] [] | 10 + jwhois | () () [] [] | 10 + kbd | [] [] | 8 + ld | [] [] | 5 + libc | [] [] [] [] | 20 + libgpewidget | | 6 + libiconv | [] [] [] [] [] [] | 21 + lifelines | [] | 2 + lilypond | [] | 4 + lingoteach | | 2 + lingoteach_lessons | () | 0 + lynx | [] [] [] [] | 14 + m4 | [] [] [] | 15 + mailutils | | 2 + make | [] [] [] [] | 15 + man-db | [] | 6 + mysecretdiary | [] [] | 8 + nano | [] [] [] | 15 + nano_1_0 | [] [] [] | 15 + opcodes | [] [] | 9 + parted | [] [] | 13 + ptx | [] [] [] | 22 + python | | 0 + radius | | 0 + recode | [] [] [] [] | 19 + screem | [] | 1 + sed | [] [] [] [] [] | 20 + sh-utils | [] [] [] | 13 + sharutils | [] [] [] [] | 16 + sketch | [] | 5 + soundtracker | [] | 7 + sp | [] | 3 + tar | [] [] [] [] [] | 24 + texinfo | [] [] [] [] | 13 + textutils | [] [] [] [] [] | 15 + tin | | 1 + util-linux | [] [] | 14 + vorbis-tools | [] | 7 + wastesedge | | 0 + wdiff | [] [] [] [] | 17 + wget | [] [] [] [] [] [] [] | 25 + xchat | [] [] [] | 11 + xpad | | 1 + +-------------------------------------------+ + 50 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + 97 domains 32 19 16 0 56 0 48 10 1 1 12 23 913 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If May 2003 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. + +Using `gettext' in new packages +=============================== + + If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +the use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`translation at iro.umontreal.ca' to make the `.pot' files available to +the translation teams. + Modified: haiku/vendor/bash/current/AUTHORS =================================================================== --- haiku/vendor/bash/current/AUTHORS 2008-02-12 08:50:02 UTC (rev 23949) +++ haiku/vendor/bash/current/AUTHORS 2008-02-12 09:02:51 UTC (rev 23950) @@ -1,6 +1,8 @@ # # Master author manifest for bash # +# The files in lib/intl were taken from the GNU gettext distribution. +# # Any files appearing in the bash distribution not listed in this file # were created by Chet Ramey. # @@ -100,6 +102,7 @@ builtins/bind.def Brian Fox, Chet Ramey builtins/break.def Brian Fox, Chet Ramey builtins/builtin.def Brian Fox, Chet Ramey +builtins/caller.def Rocky Bernstein, Chet Ramey builtins/cd.def Brian Fox, Chet Ramey builtins/colon.def Brian Fox, Chet Ramey builtins/command.def Brian Fox, Chet Ramey @@ -451,3 +454,5 @@ lib/sh/xstrchr.c Chet Ramey, Mitsuru Chinen lib/sh/zread.c Chet Ramey lib/sh/zwrite.c Chet Ramey + +tests/posix-ifs.sh Glenn Fowler Modified: haiku/vendor/bash/current/CHANGES =================================================================== --- haiku/vendor/bash/current/CHANGES 2008-02-12 08:50:02 UTC (rev 23949) +++ haiku/vendor/bash/current/CHANGES 2008-02-12 09:02:51 UTC (rev 23950) @@ -1,3 +1,1566 @@ +This document details the changes between this version, bash-3.2-release, +and the previous version, bash-3.2-beta. + +1. Changes to Bash + +a. Fixed a bug that caused the temporary environment passed to a command to + affect the shell's environment under certain circumstances. + +b. Fixed a bug in the printf builtin that caused the %q format specifier to + ignore empty string arguments. + +c. Improved multibyte character environment detection at configuration time. + +d. Fixed a bug in the read builtin that left spurious escape characters in the + input after processing backslashes when assigning to an array variable. + +2. Changes to Readline + +a. Fixed a redisplay bug that occurred in multibyte-capable locales when the + prompt was one character longer than the screen width. +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.2-beta, +and the previous version, bash-3.2-alpha. + +1. Changes to Bash + +a. Changed the lexical analyzer to treat locale-specific blank characters as + white space. + +b. Fixed a bug in command printing to avoid confusion between redirections and + process substitution. + +c. Fixed problems with cross-compiling originating from inherited environment + variables. + +d. Added write error reporting to printf builtin. + +e. Fixed a bug in the variable expansion code that could cause a core dump in + a multi-byte locale. + +f. Fixed a bug that caused substring expansion of a null string to return + incorrect results. + +g. BASH_COMMAND now retains its previous value while executing commands as the + result of a trap, as the documentation states. + +2. Changes to Readline + +a. Fixed a bug with prompt redisplay in a multi-byte locale to avoid redrawing + the prompt and input line multiple times. + +b. Fixed history expansion to not be confused by here-string redirection. + +c. Readline no longer treats read errors by converting them to newlines, as + it does with EOF. This caused partial lines to be returned from readline(). + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.2-alpha, +and the previous version, bash-3.1-release. + +1. Changes to Bash + +a. Fixed a source bug that caused the minimal configuration to not compile. + +b. Fixed memory leaks in error handling for the `read' builtin. + +c. Changed the [[ and (( compound commands to set PIPESTATUS with their exit + status. + +d. Fixed some parsing problems with compound array assignments. + +e. Added additional configuration changes for: NetBSD (incomplete multibyte + character support) + +f. Fixed two bugs with local array variable creation when shadowing a variable + of the same name from a previous context. + +g. Fixed the `read' builtin to restore the correct set of completion functions + if a timeout occurs. + +h. Added code to defer the initialization of HISTSIZE (and its stifling of the + history list) until the history file is loaded, allowing a startup file to + override the default value. + +i. Tightened up the arithmetic expression parsing to produce better error + messages when presented with invalid operators. + +j. Fixed the cross-compilation support to build the signal list at shell + invocation rather than compile time if cross-compiling. + +k. Fixed multibyte support for non-gcc compilers (or compilers that do not + allow automatic array variable sizing based on a non-constant value). + +l. Several fixes to the code that manages the list of terminated jobs and + their exit statuses, and the list of active and recently-terminated jobs + to avoid pid aliasing/wraparound and allocation errors. + +m. Fixed a problem that allowed scripts to die due to SIGINT while waiting + for children, even when started in the background or otherwise ignoring + SIGINT. + +n. Fixed a bug that caused shells invoked as -/bin/bash from not being + recognized as login shells. + +o. Fixed a problem that caused shells in the background to give the terminal + to a process group other than the foreground shell process group. + +p. Fixed a problem with extracting the `varname' in ${#varname}. + +q. Fixed the code that handles SIGQUIT to not exit immediately -- thereby + calling functions that may not be called in a signal handler context -- + but set a flag and exit afterward (like SIGINT). + +r. Changed the brace expansion code to skip over braces that don't begin a + valid matched brace expansion construct. + +s. Fixed `typeset' and `declare' to not require that their shell function + operands to be valid shell identifiers. + +t. Changed `test' to use access(2) with a temporary uid/euid swap when testing + file attributes and running setuid, and access(2) in most other cases. + +u. Changed completion code to not attempt command name completion on a line + consisting solely of whitespace when no_empty_command_completion is set. + +v. The `hash' builtin now prints nothing in posix mode when the hash table is + empty, and prints a message to that effect to stdout instead of stderr + when not in posix mode. + +w. Fixed a bug in the extended pattern matching code that caused it to fail to + match periods with certain patterns. + +x. Fixed a bug that caused the shell to dump core when performing filename + generation in directories with thousands of files. + +y. Returned to the original Bourne shell rules for parsing ``: no recursive + parsing of embedded quoted strings or ${...} constructs. + +z. The inheritence of the DEBUG, RETURN, and ERR traps is now dependent only + on the settings of the `functrace' and `errtrace' shell options, rather + than whether or not the shell is in debugging mode. + +aa. Fixed a problem with $HOME being converted to ~ in the expansion of + members of the DIRSTACK array. + +bb. Fixed a problem with quoted arguments to arithmetic expansions in certain + constructs. + +cc. The command word completion code now no longer returns matching directories + while searching $PATH. + +dd. Fixed a bug with zero-padding and precision handling in snprintf() + replacement. + +ee. Fixed a bug that caused the command substitution code not to take embedded + shell comments into account. + +ff. Fixed a bug that caused $((...);(...)) to be misinterpreted as an + arithmetic substitution. + +gg. Fixed a bug in the prompt expansion code that inappropriately added a + \001 before a \002 under certain circumstances. + +hh. Fixed a bug that caused `unset LANG' to not properly reset the locale + (previous versions would set the locale back to what it was when bash + was started rather than the system's "native" locale). + +ii. Fixed a bug that could cause file descriptors > 10 to not be closed even + when closed explicitly by a script. + +jj. Fixed a bug that caused single quotes to be stripped from ANSI-C quoting + inside double-quoted command substitutions. + +kk. Fixed a bug that could cause core dumps when `return' was executed as the + last element of a pipeline inside a shell function. + +ll. Fixed a bug that caused DEBUG trap strings to overwrite commands stored in + the jobs list. + +2. Changes to Readline + +a. Fixed a problem that caused segmentation faults when using readline in + callback mode and typing consecutive DEL characters on an empty line. + +b. Fixed several redisplay problems with multibyte characters, all having to + do with the different code paths and variable meanings between single-byte + and multibyte character redisplay. + +c. Fixed a problem with key sequence translation when presented with the + sequence \M-\C-x. + +d. Fixed a problem that prevented the `a' command in vi mode from being + undone and redone properly. + +e. Fixed a problem that prevented empty inserts in vi mode from being undone + properly. + +f. Fixed a problem that caused readline to initialize with an incorrect idea + of whether or not the terminal can autowrap. + +g. Fixed output of key bindings (like bash `bind -p') to honor the setting of + convert-meta and use \e where appropriate. + +h. Changed the default filename completion function to call the filename + dequoting function if the directory completion hook isn't set. This means + that any directory completion hooks need to dequote the directory name, + since application-specific hooks need to know how the word was quoted, + even if no other changes are made. + +i. Fixed a bug with creating the prompt for a non-interactive search string + when there are non-printing characters in the primary prompt. + +j. Fixed a bug that caused prompts with invisible characters to be redrawn + multiple times in a multibyte locale. + +k. Fixed a bug that could cause the key sequence scanning code to return the + wrong function. + +l. Fixed a problem with the callback interface that caused it to fail when + using multi-character keyboard macros. + +m. Fixed a bug that could cause a core dump when an edited history entry was + re-executed under certain conditions. + +n. Fixed a bug that caused readline to reference freed memory when attmpting + to display a portion of the prompt. + +3. New Features in Bash + +a. Changed the parameter pattern replacement functions to not anchor the + pattern at the beginning of the string if doing global replacement - that + combination doesn't make any sense. + +b. When running in `word expansion only' mode (--wordexp option), inhibit + process substitution. + +c. Loadable builtins now work on MacOS X 10.[34]. + +d. Shells running in posix mode no longer set $HOME, as POSIX requires. + +e. The code that checks for binary files being executed as shell scripts now + checks only for NUL rather than any non-printing character. + +f. Quoting the string argument to the [[ command's =~ operator now forces + string matching, as with the other pattern-matching operators. + +4. New Features in Readline + +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. + +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. + +c. The history file reading functions now allow windows-like \r\n line + terminators. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-release, +and the previous version, bash-3.1-rc2. + +1. Changes to Readline + +a. Several changes to the multibyte redisplay code to fix problems with + prompts containing invisible characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-rc2, +and the previous version, bash-3.1-rc1. + +1. Changes to Bash + +a. Fixed a bug that caused a DEBUG trap to overwrite a command string that's + eventually attached to a background job. + +b. Changed some code so that filenames with leading tildes with spaces in the + name aren't tilde-expanded by the bash completion code. + +c. Fixed a bug that caused the pushd builtin to fail to change to + directories with leading `-'. + +d. Fixed a small memory leak in the programmable completion code. + +2. Changes to Readline + +a. Fixed a redisplay bug caused by moving the cursor vertically to a line + with invisible characters in the prompt in a multibyte locale. + +b. Fixed a bug that could cause the terminal special chars to be bound in the + wrong keymap in vi mode. + +3. New Features in Bash + +a. If compiled for strict POSIX conformance, LINES and COLUMNS may now + override the true terminal size. + +4. New Features in Readline + +a. A new external application-controllable variable that allows the LINES + and COLUMNS environment variables to set the window size regardless of + what the kernel returns. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-rc1, +and the previous version, bash-3.1-beta1. + +1. Changes to Bash + +a. Fixed a bug that could cause core dumps due to accessing the current + pipeline while in the middle of modifying it. + +b. Fixed a bug that caused pathnames with backslashes still quoting characters + to be passed to opendir(). + +c. Command word completion now obeys the setting of completion-ignore-case. + +d. Fixed a problem with redirection that caused file descriptors greater than + 2 to be inappropriately marked as close-on-exec. + +e. In Posix mode, after `wait' is called to wait for a particular process + explicitly, that process is removed from the list of processes known to + the shell, and subsequent attempts to wait for it return errors. + +f. Fixed a bug that caused extended pattern matching to incorrectly scan + backslash-escaped pattern characters. + +g. Fixed a synchronization problem that could cause core dumps when handling + a SIGWINCH. + +h. Fixed a bug that caused an unmatched backquote to be accepted without an + error when processing here documents. + +i. Fixed a small memory leak in the `cd' builtin. + +j. Fix for MacOS X so it gets the values for the HOSTTYPE, MACHTYPE, and + OSTYPE variables at build time, to support universal binaries. [... truncated: 152270 lines follow ...] From jackburton at mail.berlios.de Tue Feb 12 11:03:47 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 12 Feb 2008 11:03:47 +0100 Subject: [Haiku-commits] r23951 - in haiku/vendor/bash/current: . cross-build lib/readline/doc lib/tilde tests Message-ID: <200802121003.m1CA3ltV018434@sheep.berlios.de> Author: jackburton Date: 2008-02-12 11:03:32 +0100 (Tue, 12 Feb 2008) New Revision: 23951 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23951&view=rev Removed: haiku/vendor/bash/current/cross-build/beos-sig.h haiku/vendor/bash/current/cross-build/win32sig.h haiku/vendor/bash/current/lib/readline/doc/hist.texinfo haiku/vendor/bash/current/lib/readline/doc/hstech.texinfo haiku/vendor/bash/current/lib/readline/doc/hsuser.texinfo haiku/vendor/bash/current/lib/readline/doc/manvers.texinfo haiku/vendor/bash/current/lib/readline/doc/rlman.texinfo haiku/vendor/bash/current/lib/readline/doc/rltech.texinfo haiku/vendor/bash/current/lib/readline/doc/rluser.texinfo haiku/vendor/bash/current/lib/readline/doc/rluserman.texinfo haiku/vendor/bash/current/lib/tilde/doc/ haiku/vendor/bash/current/pathnames.h haiku/vendor/bash/current/tests/braces-tests haiku/vendor/bash/current/tests/tilde-tests Log: This completes the previous commit, deleting files which aren't in the new version. Deleted: haiku/vendor/bash/current/cross-build/beos-sig.h Deleted: haiku/vendor/bash/current/cross-build/win32sig.h Deleted: haiku/vendor/bash/current/lib/readline/doc/hist.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/hstech.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/hsuser.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/manvers.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/rlman.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/rltech.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/rluser.texinfo Deleted: haiku/vendor/bash/current/lib/readline/doc/rluserman.texinfo Deleted: haiku/vendor/bash/current/pathnames.h Deleted: haiku/vendor/bash/current/tests/braces-tests Deleted: haiku/vendor/bash/current/tests/tilde-tests From jackburton at mail.berlios.de Tue Feb 12 11:07:13 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 12 Feb 2008 11:07:13 +0100 Subject: [Haiku-commits] r23952 - haiku/vendor/bash Message-ID: <200802121007.m1CA7DFg018782@sheep.berlios.de> Author: jackburton Date: 2008-02-12 11:07:09 +0100 (Tue, 12 Feb 2008) New Revision: 23952 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23952&view=rev Added: haiku/vendor/bash/3.2/ Log: tagging bash 3.2 Copied: haiku/vendor/bash/3.2 (from rev 23951, haiku/vendor/bash/current) From k_lurie at gbrener.org.il Tue Feb 12 14:55:27 2008 From: k_lurie at gbrener.org.il (Kobi Lurie) Date: Tue, 12 Feb 2008 15:55:27 +0200 Subject: [Haiku-commits] r23935 - in haiku/trunk/src: apps/cdplayer apps/deskcalc apps/midiplayer apps/soundrecorder apps/tv preferences/screensaver tests/kits/game/chart tests/servers/app/bitmap_drawing In-Reply-To: <47B0E951.4040503@myhaiku.org> References: <23027334203-BeMail@kirilla> <47B0E951.4040503@myhaiku.org> Message-ID: <47B1A54F.3070000@gbrener.org.il> Yes, I agree with koki (as an "international" user :)) in Israel, for windows, there is a localized version (translated and all) and an enabled version (input and bidi) and most people prefer the enabled. besides that, I usually prefer the original name to stay intact, instead of coming up with some kind of made-up name. (adds to confusion when communicating) about the menu's and all the text labels, and input methods, there is no doubt about translating and implementing them but regarding the application names, there is practically no need. still, just my humble opinion. In Israel, English is a second language, and it's much easier to prefer the english terms, but it might be different in other countries. kobi Jorge G. Mare (a.k.a. Koki) wrote: > Hi Jonas, > > Jonas Sundstr?m wrote: > >> "Jorge G. Mare (a.k.a. Koki)" wrote: >> ... >> >>> I have participated in numerous localization projects, >>> and I can say with a high degree of confidence that >>> non-English users don't necessarily translate all the >>> name apps. For example, you can expect apps like >>> Pulse, CodyCam, Icon-O-Matic, etc., not to be translated, >>> and non-English users will still be able to identify by >>> their original name. >>> >> Yes, people always get by somehow. >> >> But if those names were less monolithic, less name-ish, >> they could more easily be localized, and that would >> probably benefit a lot of people. (English may not be >> the primary international language 20 years from now.) >> > > It's not really that people are being forced to get by. In many cases > users (and even businesses who market software) simply prefer to use the > English names for various reasons (ie., the cool factor, because it is > more practical, easier to support, etc.). This sort of differentiation > actually helps you build your brand. > > All IMHO and FWIW disclaimers apply. :) > > Cheers, > > Koki > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > > From grzegorz.dabrowski at gmail.com Tue Feb 12 20:52:48 2008 From: grzegorz.dabrowski at gmail.com (Grzegorz =?us-ascii?Q?D=5F=5Fbrowski?=) Date: Tue, 12 Feb 2008 19:52:48 +0000 Subject: [Haiku-commits] r23930 - haiku/trunk/src/system/runtime_loader In-Reply-To: <200802080318.m183ISnJ007309@sheep.berlios.de> References: <200802080318.m183ISnJ007309@sheep.berlios.de> Message-ID: <20080212195248.38c3007d@gmail.com> On Fri, 8 Feb 2008 04:18:28 +0100 bonefish at BerliOS wrote: > Author: bonefish > Date: 2008-02-08 04:18:26 +0100 (Fri, 08 Feb 2008) > New Revision: 23930 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23930&view=rev > > Modified: > haiku/trunk/src/system/runtime_loader/elf.cpp > Log: > Normalize the given image path in load_container(). Just constructing > some absolute path was not enough to always recognize a library as > already loaded. This fixes problems with Perl where loading an add-on > would cause another instance of libperl.so to be loaded, which would > lead to crashes due to uninitialized static vars in the new instance. > Perl builds now and the tests run, but quite a few do fail. Thank you! Perl really works, but something is still wrong with runtime loader. Sometimes I get an error: ~>script.pl Can't open perl script "script.pl" but works fine this: ~>/boot/home/config/bin/script.pl Hello world! -- Grzegorz Dabrowski From mmlr at mail.berlios.de Tue Feb 12 21:20:38 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 12 Feb 2008 21:20:38 +0100 Subject: [Haiku-commits] r23953 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200802122020.m1CKKcqG003518@sheep.berlios.de> Author: mmlr Date: 2008-02-12 21:20:35 +0100 (Tue, 12 Feb 2008) New Revision: 23953 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23953&view=rev Modified: haiku/trunk/headers/private/kernel/tracing_config.h haiku/trunk/src/system/kernel/heap.cpp Log: Adding two debug features to the new heap implementation: * Tracing of allocations, reallocations and frees * Leak checking infrastructure to dump allocations The leak checking code records the team and thread id when an allocation is made as well as stores the originally requested size. It also adds the "allocations" debugger command that can dump all current allocations (usually a huge list) or filter by either a team or thread id. This way it's easily possible to find leftover allocations of no more active teams/threads. Combined with the tracing support one might be able to track down the time and reason of an allocation and possibly find the corresponding leak if it is one. Note that kernel heap leak checking has to be enabled manually by setting the KERNEL_HEAP_LEAK_CHECK define to 1. Modified: haiku/trunk/headers/private/kernel/tracing_config.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-12 10:07:09 UTC (rev 23952) +++ haiku/trunk/headers/private/kernel/tracing_config.h 2008-02-12 20:20:35 UTC (rev 23953) @@ -18,6 +18,7 @@ //#define BMESSAGE_TRACING //#define BLOCK_CACHE_TRANSACTION_TRACING +//#define KERNEL_HEAP_TRACING //#define RUNTIME_LOADER_TRACING //#define SIGNAL_TRACING //#define SYSCALL_TRACING Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-12 10:07:09 UTC (rev 23952) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-12 20:20:35 UTC (rev 23953) @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include //#define TRACE_HEAP @@ -31,7 +34,17 @@ #define PARANOID_KFREE 1 // validate sanity of the heap after each operation (slow!) #define PARANOID_VALIDATION 0 +// store size, thread and team info at the end of each allocation block +#define KERNEL_HEAP_LEAK_CHECK 0 +#if KERNEL_HEAP_LEAK_CHECK +typedef struct heap_leak_check_info_s { + size_t size; + thread_id thread; + team_id team; +} heap_leak_check_info; +#endif + typedef struct heap_page_s { uint16 index; uint16 bin_index : 5; @@ -74,6 +87,83 @@ static sem_id sHeapGrownNotify = -1; +// #pragma mark - Tracing + +#ifdef KERNEL_HEAP_TRACING +namespace KernelHeapTracing { + +class Allocate : public AbstractTraceEntry { + public: + Allocate(addr_t address, size_t size) + : fAddress(address), + fSize(size) + { + Initialized(); + } + + virtual void AddDump(TraceOutput &out) + { + out.Print("heap allocate: 0x%08lx (%lu bytes)", fAddress, fSize); + } + + private: + addr_t fAddress; + size_t fSize; +}; + + +class Reallocate : public AbstractTraceEntry { + public: + Reallocate(addr_t oldAddress, addr_t newAddress, size_t newSize) + : fOldAddress(oldAddress), + fNewAddress(newAddress), + fNewSize(newSize) + { + Initialized(); + }; + + virtual void AddDump(TraceOutput &out) + { + out.Print("heap reallocate: 0x%08lx -> 0x%08lx (%lu bytes)", + fOldAddress, fNewAddress, fNewSize); + } + + private: + addr_t fOldAddress; + addr_t fNewAddress; + size_t fNewSize; +}; + + +class Free : public AbstractTraceEntry { + public: + Free(addr_t address) + : fAddress(address) + { + Initialized(); + }; + + virtual void AddDump(TraceOutput &out) + { + out.Print("heap free: 0x%08lx", fAddress); + } + + private: + addr_t fAddress; +}; + + +} // namespace KernelHeapTracing + +# define T(x) if (!kernel_startup) new(std::nothrow) KernelHeapTracing::x; +#else +# define T(x) ; +#endif + + +// #pragma mark - Debug functions + + static void dump_page(heap_page *page) { @@ -129,6 +219,104 @@ } +#if KERNEL_HEAP_LEAK_CHECK +static int +dump_allocations(int argc, char **argv) +{ + team_id team = -1; + thread_id thread = -1; + if (argc == 3) { + if (strcmp(argv[1], "team") == 0) + team = strtoul(argv[2], NULL, 0); + else if (strcmp(argv[1], "thread") == 0) + thread = strtoul(argv[2], NULL, 0); + else { + print_debugger_command_usage(argv[0]); + return 0; + } + } else if (argc != 1) { + print_debugger_command_usage(argv[0]); + return 0; + } + + size_t totalSize = 0; + uint32 totalCount = 0; + heap_allocator *heap = sHeapList; + while (heap) { + // go through all the pages + heap_leak_check_info *info = NULL; + for (uint32 i = 0; i < heap->page_count; i++) { + heap_page *page = &heap->page_table[i]; + if (!page->in_use) + continue; + + addr_t base = heap->base + i * B_PAGE_SIZE; + if (page->bin_index < heap->bin_count) { + // page is used by a small allocation bin + uint32 elementCount = page->empty_index; + size_t elementSize = heap->bins[page->bin_index].element_size; + for (uint32 j = 0; j < elementCount; j++, base += elementSize) { + // walk the free list to see if this element is in use + bool elementInUse = true; + for (addr_t *temp = page->free_list; temp != NULL; temp = (addr_t *)*temp) { + if ((addr_t)temp == base) { + elementInUse = false; + break; + } + } + + if (!elementInUse) + continue; + + info = (heap_leak_check_info *)(base + elementSize + - sizeof(heap_leak_check_info)); + + if ((team == -1 && thread == -1) + || (team == -1 && info->thread == thread) + || (thread == -1 && info->team == team)) { + // interesting... + dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", + info->team, info->thread, base, info->size); + totalSize += info->size; + totalCount++; + } + } + } else { + // page is used by a big allocation, find the page count + uint32 pageCount = 1; + while (i + pageCount < heap->page_count + && heap->page_table[i + pageCount].in_use + && heap->page_table[i + pageCount].bin_index == heap->bin_count + && heap->page_table[i + pageCount].allocation_id == page->allocation_id) + pageCount++; + + info = (heap_leak_check_info *)(base + pageCount * B_PAGE_SIZE + - sizeof(heap_leak_check_info)); + + if ((team == -1 && thread == -1) + || (team == -1 && info->thread == thread) + || (thread == -1 && info->team == team)) { + // interesting... + dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", + info->team, info->thread, base, info->size); + totalSize += info->size; + totalCount++; + } + + // skip the allocated pages + i += pageCount - 1; + } + } + + heap = heap->next; + } + + dprintf("total allocations: %lu; total bytes: %lu\n", totalCount, totalSize); + return 0; +} +#endif // KERNEL_HEAP_LEAK_CHECK + + #if PARANOID_VALIDATION static void heap_validate_heap(heap_allocator *heap) @@ -238,9 +426,12 @@ mutex_unlock(&heap->lock); } -#endif +#endif // PARANOID_VALIDATION +// #pragma mark - Heap functions + + heap_allocator * heap_attach(addr_t base, size_t size, bool postSem) { @@ -371,6 +562,13 @@ page->next = page->prev = NULL; } +#if KERNEL_HEAP_LEAK_CHECK + heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + + bin->element_size - sizeof(heap_leak_check_info)); + info->size = size - sizeof(heap_leak_check_info); + info->thread = (kernel_startup ? 0 : thread_get_current_thread_id()); + info->team = (kernel_startup ? 0 : team_get_current_team_id()); +#endif return address; } @@ -400,6 +598,15 @@ bin->page_list = page; } +#if KERNEL_HEAP_LEAK_CHECK + heap_leak_check_info *info = (heap_leak_check_info *)(heap->base + + page->index * B_PAGE_SIZE + bin->element_size + - sizeof(heap_leak_check_info)); + info->size = size - sizeof(heap_leak_check_info); + info->thread = (kernel_startup ? 0 : thread_get_current_thread_id()); + info->team = (kernel_startup ? 0 : team_get_current_team_id()); +#endif + // we return the first slot in this page return (void *)(heap->base + page->index * B_PAGE_SIZE); } @@ -441,6 +648,13 @@ page->allocation_id = allocationID; } +#if KERNEL_HEAP_LEAK_CHECK + heap_leak_check_info *info = (heap_leak_check_info *)(heap->base + + (first + pageCount) * B_PAGE_SIZE - sizeof(heap_leak_check_info)); + info->size = size - sizeof(heap_leak_check_info); + info->thread = (kernel_startup ? 0 : thread_get_current_thread_id()); + info->team = (kernel_startup ? 0 : team_get_current_team_id()); +#endif return (void *)(heap->base + first * B_PAGE_SIZE); } @@ -468,6 +682,10 @@ mutex_lock(&heap->lock); +#if KERNEL_HEAP_LEAK_CHECK + size += sizeof(heap_leak_check_info); +#endif + // ToDo: that code "aligns" the buffer because the bins are always // aligned on their bin size if (size < alignment) @@ -491,6 +709,11 @@ || heap->free_pages->next->next == NULL); } +#if KERNEL_HEAP_LEAK_CHECK + size -= sizeof(heap_leak_check_info); +#endif + + T(Allocate((addr_t)address, size)); mutex_unlock(&heap->lock); if (address == NULL) return address; @@ -619,6 +842,7 @@ } } + T(Free((addr_t)address)); mutex_unlock(&heap->lock); return B_OK; } @@ -670,14 +894,32 @@ mutex_unlock(&heap->lock); +#if KERNEL_HEAP_LEAK_CHECK + newSize += sizeof(heap_leak_check_info); +#endif + // does the new allocation simply fit in the old allocation? if (newSize > minSize && newSize <= maxSize) { +#if KERNEL_HEAP_LEAK_CHECK + // update the size info (the info is at the end so stays where it is) + heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + maxSize); + info->size = newSize - sizeof(heap_leak_check_info); + newSize -= sizeof(heap_leak_check_info); +#endif + + T(Reallocate((addr_t)address, (addr_t)address, newSize)); *newAddress = address; return B_OK; } +#if KERNEL_HEAP_LEAK_CHECK + // new leak check info will be created with the malloc below + newSize -= sizeof(heap_leak_check_info); +#endif + // if not, allocate a new chunk of memory *newAddress = malloc(newSize); + T(Reallocate((addr_t)address, (addr_t)*newAddress, newSize)); if (*newAddress == NULL) { // we tried but it didn't work out, but still the operation is done return B_OK; @@ -749,7 +991,15 @@ sHeapList = heap_attach(base, size, false); // set up some debug commands - add_debugger_command("heap", &dump_heap_list, "dump stats about the kernel heap(s)"); + add_debugger_command("heap", &dump_heap_list, "Dump stats about the kernel heap(s)"); +#if KERNEL_HEAP_LEAK_CHECK + add_debugger_command_etc("allocations", &dump_allocations, + "Dump current allocations", "[(\"team\" | \"thread\") ]\n" + "If no parameters are given, all current alloactions are dumped.\n" + "If either \"team\" or \"thread\" is specified as the first argument,\n" + "only allocations matching the team or thread id given in the second\n" + "argument are printed.\n", 0); +#endif return B_OK; } @@ -794,7 +1044,7 @@ } -// #pragma mark - +// #pragma mark - Public API void * From oruizdorantes at mail.berlios.de Tue Feb 12 21:56:30 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Tue, 12 Feb 2008 21:56:30 +0100 Subject: [Haiku-commits] r23954 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802122056.m1CKuUoo007162@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-12 21:56:29 +0100 (Tue, 12 Feb 2008) New Revision: 23954 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23954&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c Log: Thanks pointing this out Axel, my commits mails were arriving to a dead mail and I did not read until now. My apologiesfor delay Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-02-12 20:20:35 UTC (rev 23953) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-02-12 20:56:29 UTC (rev 23954) @@ -24,6 +24,7 @@ }; + snet_buffer* snb_create(uint16 size) { @@ -64,12 +65,14 @@ } + inline void snb_reset(snet_buffer* snb) { snb->puttingSize = snb->pullingSize = 0; } + void snb_free(snet_buffer* snb) { @@ -85,6 +88,7 @@ } + inline void* snb_get(snet_buffer* snb) { @@ -92,6 +96,7 @@ return snb->buffer; } + inline uint16 snb_size(snet_buffer* snb) { @@ -99,6 +104,7 @@ return snb->expectedSize; } + inline void* snb_cookie(snet_buffer* snb) { @@ -106,6 +112,7 @@ return snb->cookie; } + inline void snb_set_cookie(snet_buffer* snb, void* cookie) { @@ -113,18 +120,21 @@ snb->cookie = cookie; } + /* Return true if we canot "put" more data in the buffer */ inline bool snb_completed(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize == snb->puttingSize)); } + /* Return true if we cannot pull more more data from the buffer */ inline bool snb_finished(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize == snb->pullingSize)); } + inline bool snb_remaining_to_put(snet_buffer* snb) { return (snb != NULL && (snb->expectedSize - snb->puttingSize)); @@ -136,6 +146,7 @@ return (snb != NULL && (snb->expectedSize - snb->pullingSize)); } + /* ISSUE1: Number of packets in the worst case(we always need a bigger buffer than before) increases, never decreases: @@ -168,6 +179,7 @@ } + void snb_park(struct list* l, snet_buffer* snb) { @@ -179,6 +191,7 @@ } } + snet_buffer* snb_fetch(struct list* l, uint16 size) { From oruizdorantes at mail.berlios.de Tue Feb 12 22:08:44 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Tue, 12 Feb 2008 22:08:44 +0100 Subject: [Haiku-commits] r23955 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802122108.m1CL8iJ1008388@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-12 22:08:43 +0100 (Tue, 12 Feb 2008) New Revision: 23955 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23955&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h Log: Build the device path in devfs from the configuration file Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2008-02-12 20:56:29 UTC (rev 23954) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h 2008-02-12 21:08:43 UTC (rev 23955) @@ -8,13 +8,14 @@ #ifndef _H2CFG_H_ #define _H2CFG_H_ -/* TODO: move exclusive header for drivers*/ + #define BT_DRIVER_SUPPORTS_CMD 1 #define BT_DRIVER_SUPPORTS_EVT 1 #define BT_DRIVER_SUPPORTS_ESCO 0 #define BT_DRIVER_SUPPORTS_SCO 0 #define BT_DRIVER_SUPPORTS_ACL 0 +/* TODO: move exclusive header for drivers*/ #define BT_DRIVER_RXCOVERAGE (BT_DRIVER_SUPPORTS_EVT+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) #define BT_DRIVER_TXCOVERAGE (BT_DRIVER_SUPPORTS_CMD+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) @@ -22,11 +23,21 @@ #error incomplete Bluetooth driver Commands and Events should be implemented #endif +#define BT_SURVIVE_WITHOUT_HCI +#define BT_SURVIVE_WITHOUT_NET_BUFFERS //////////////////////////////////// -#define BT_SURVIVE_WITHOUT_HCI -#define BT_SURVIVE_WITHOUT_NET_BUFFERS +#ifndef BLUETOOTH_DEVICE_TRANSPORT +#error BLUETOOTH_DEVICE_TRANSPORT must be defined to build the publishing path +#endif +#ifndef BLUETOOTH_DEVICE_NAME +#error BLUETOOTH_DEVICE_NAME must be defined to build the publishing path +#endif +#define BLUETOOTH_DEVICE_DEVFS_NAME BLUETOOTH_DEVICE_TRANSPORT BLUETOOTH_DEVICE_NAME +#define BLUETOOTH_DEVICE_PATH "bluetooth/" BLUETOOTH_DEVICE_DEVFS_NAME + + #endif Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-12 20:56:29 UTC (rev 23954) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-12 21:08:43 UTC (rev 23955) @@ -96,14 +96,14 @@ memset(new_bt_dev, 0, sizeof(bt_usb_dev) ); /* We will need this sem for some flow control */ - new_bt_dev->cmd_complete = create_sem(1, ID "cmd_complete"); + new_bt_dev->cmd_complete = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "cmd_complete"); if (new_bt_dev->cmd_complete < 0) { err = new_bt_dev->cmd_complete; goto bail0; } /* and this for something else */ - new_bt_dev->lock = create_sem(1, ID "lock"); + new_bt_dev->lock = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "lock"); if (new_bt_dev->lock < 0) { err = new_bt_dev->lock; goto bail1; @@ -114,7 +114,7 @@ for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { if (bt_usb_devices[i] == NULL) { bt_usb_devices[i] = new_bt_dev; - sprintf(new_bt_dev->name, "%s/%ld", DEVICE_PATH, i); + sprintf(new_bt_dev->name, "%s/%ld", BLUETOOTH_DEVICE_PATH, i); new_bt_dev->num = i; debugf("added device %p %ld %s\n", bt_usb_devices[i] ,new_bt_dev->num,new_bt_dev->name); break; @@ -556,7 +556,7 @@ status_t err = B_OK; bt_usb_dev* dev = (bt_usb_dev*)cookie; - debugf("device_free() called on \"%s %ld\"\n",DEVICE_PATH, dev->num); + debugf("device_free() called on %s \n",BLUETOOTH_DEVICE_PATH); if (--dev->open_count == 0) { @@ -693,7 +693,7 @@ debugf("nb module at %p\n", nb); // GENERAL INITS - dev_table_sem = create_sem(1, ID "dev_table_lock"); + dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock"); if (dev_table_sem < 0) { goto err; } @@ -704,8 +704,8 @@ /* After here device_added and publish devices hooks are called be carefull USB devs */ - usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); - usb->install_notify(DEVICE_NAME, ¬ify_hooks); + usb->register_driver(BLUETOOTH_DEVICE_DEVFS_NAME, supported_devices, 1, NULL); + usb->install_notify(BLUETOOTH_DEVICE_DEVFS_NAME, ¬ify_hooks); return B_OK; @@ -740,8 +740,7 @@ } - usb->uninstall_notify(DEVICE_NAME); - usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); + usb->uninstall_notify(BLUETOOTH_DEVICE_DEVFS_NAME); /* Releasing modules */ put_module(usb_name); Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2008-02-12 20:56:29 UTC (rev 23954) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h 2008-02-12 21:08:43 UTC (rev 23955) @@ -17,7 +17,6 @@ #include -#include "h2cfg.h" #include "snet_buffer.h" /* USB definitions for the generic device*/ @@ -25,11 +24,11 @@ #define UDSUBCLASS_RF 0x01 #define UDPROTO_BLUETOOTH 0x01 -#define TRANSPORT_NAME "h2" -#define DEVICE_NAME "generic" -#define DEVICE_PATH "bus/bluetooth/" TRANSPORT_NAME "/" DEVICE_NAME +#define BLUETOOTH_DEVICE_TRANSPORT "h2" +#define BLUETOOTH_DEVICE_NAME "generic" +#include "h2cfg.h" -#define ID DEVICE_NAME ": " /* prefix for debug messages */ +//#define ID DEVICE_NAME ": " /* prefix for debug messages */ #define USB_TYPE_CLASS (0x01 << 5) /// Check if it is in some other header #define USB_TYPE_VENDOR (0x02 << 5) From mmlr at mail.berlios.de Tue Feb 12 23:25:19 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 12 Feb 2008 23:25:19 +0100 Subject: [Haiku-commits] r23956 - haiku/trunk/src/system/kernel Message-ID: <200802122225.m1CMPJ8b016927@sheep.berlios.de> Author: mmlr Date: 2008-02-12 23:25:18 +0100 (Tue, 12 Feb 2008) New Revision: 23956 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23956&view=rev Modified: haiku/trunk/src/system/kernel/heap.cpp Log: Only clear 0xdeadbeef if there is 0xdeadbeef present. The size field of the heap leak check info would otherwise be overwritten for allocations that still fit the 16 byte bin (i.e. allocations of 0-4 bytes). Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-12 21:08:43 UTC (rev 23955) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-12 22:25:18 UTC (rev 23956) @@ -721,7 +721,8 @@ #if PARANOID_KFREE // make sure 0xdeadbeef is cleared if we do not overwrite the memory // and the user does not clear it - ((uint32 *)address)[1] = 0xcccccccc; + if (((uint32 *)address)[1] == 0xdeadbeef) + ((uint32 *)address)[1] = 0xcccccccc; #endif #if PARANOID_KMALLOC From oruizdorantes at mail.berlios.de Wed Feb 13 21:07:52 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Wed, 13 Feb 2008 21:07:52 +0100 Subject: [Haiku-commits] r23957 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802132007.m1DK7qXs032170@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-13 21:07:51 +0100 (Wed, 13 Feb 2008) New Revision: 23957 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23957&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c Log: Make the driver almost build for target R5. How is the best way in the Jamfile to compile it together with src/system/kernel/util/list.c only for target R5? Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-02-12 22:25:18 UTC (rev 23956) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-02-13 20:07:51 UTC (rev 23957) @@ -30,7 +30,6 @@ void command_complete(void* cookie, uint32 status, void* data, uint32 actual_len); void event_complete(void* cookie, uint32 status, void* data, uint32 actual_len); #else -/* TODO: propagate this definitions */ void acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len); void acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len); void command_complete(void* cookie, status_t status, void* data, size_t actual_len); @@ -167,7 +166,11 @@ void +#ifndef HAIKU_TARGET_PLATFORM_HAIKU +event_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +#else event_complete(void* cookie, status_t status, void* data, size_t actual_len) +#endif { bt_usb_dev* bdev = cookie; @@ -201,8 +204,13 @@ } + void +#ifndef HAIKU_TARGET_PLATFORM_HAIKU +acl_rx_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +#else acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len) +#endif { bt_usb_dev* bdev = cookie; status_t err; @@ -234,10 +242,12 @@ } } + #if 0 #pragma mark --- RX --- #endif + status_t submit_rx_event(bt_usb_dev* bdev) { @@ -304,12 +314,11 @@ #pragma mark --- TX Complete --- #endif -#ifndef HAIKU void +#ifndef HAIKU_TARGET_PLATFORM_HAIKU +command_complete(void* cookie, uint32 status, void* data, uint32 actual_len) +#else command_complete(void* cookie, status_t status, void* data, size_t actual_len) -#else -void -command_complete(void* cookie, uint32 status, void* data, size_t actual_len) #endif { snet_buffer* snbuf = (snet_buffer*) cookie; From mmu_man at mail.berlios.de Wed Feb 13 23:19:05 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 13 Feb 2008 23:19:05 +0100 Subject: [Haiku-commits] r23958 - in haiku/trunk/3rdparty/mmu_man: . scripts Message-ID: <200802132219.m1DMJ5vh012254@sheep.berlios.de> Author: mmu_man Date: 2008-02-13 23:19:05 +0100 (Wed, 13 Feb 2008) New Revision: 23958 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23958&view=rev Added: haiku/trunk/3rdparty/mmu_man/scripts/ haiku/trunk/3rdparty/mmu_man/scripts/bebook haiku/trunk/3rdparty/mmu_man/scripts/bman Log: A place to put various shell scripts I wrote. The first too are command line wrappers to BeHappy, that selects either BeBook or Man pages and asks it to find the argument. Added: haiku/trunk/3rdparty/mmu_man/scripts/bebook =================================================================== --- haiku/trunk/3rdparty/mmu_man/scripts/bebook 2008-02-13 20:07:51 UTC (rev 23957) +++ haiku/trunk/3rdparty/mmu_man/scripts/bebook 2008-02-13 22:19:05 UTC (rev 23958) @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -z "$1" ]; then +echo "usage:" +echo "$0 search_term" +exit 0 +fi + +$(query -a '(BEOS:APP_SIG=="application/x-vnd.STertois.BeHappy")' | head -1) & +sleep 1 +LASTWIN=$(hey BeHappy count Window | grep result | cut -d ' ' -f 7) +let LASTWIN="$LASTWIN - 1" +hey BeHappy set Book of Window $LASTWIN to "Be Book" > /dev/null +hey BeHappy set Topic of Window $LASTWIN to "$1" > /dev/null Property changes on: haiku/trunk/3rdparty/mmu_man/scripts/bebook ___________________________________________________________________ Name: svn:executable + * Added: haiku/trunk/3rdparty/mmu_man/scripts/bman =================================================================== --- haiku/trunk/3rdparty/mmu_man/scripts/bman 2008-02-13 20:07:51 UTC (rev 23957) +++ haiku/trunk/3rdparty/mmu_man/scripts/bman 2008-02-13 22:19:05 UTC (rev 23958) @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -z "$1" ]; then +echo "usage:" +echo "$0 search_term" +exit 0 +fi + +$(query -a '(BEOS:APP_SIG=="application/x-vnd.STertois.BeHappy")' | head -1) & +sleep 1 +LASTWIN=$(hey BeHappy count Window | grep result | cut -d ' ' -f 7) +let LASTWIN="$LASTWIN - 1" +hey BeHappy set Book of Window $LASTWIN to "Man pages" > /dev/null +hey BeHappy set Topic of Window $LASTWIN to "$1" > /dev/null Property changes on: haiku/trunk/3rdparty/mmu_man/scripts/bman ___________________________________________________________________ Name: svn:executable + * From mmu_man at mail.berlios.de Thu Feb 14 23:53:35 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 14 Feb 2008 23:53:35 +0100 Subject: [Haiku-commits] r23959 - haiku/trunk/src/bin Message-ID: <200802142253.m1EMrZxh025068@sheep.berlios.de> Author: mmu_man Date: 2008-02-14 23:53:34 +0100 (Thu, 14 Feb 2008) New Revision: 23959 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23959&view=rev Modified: haiku/trunk/src/bin/open.cpp Log: * make sure an url mime type is registered before using it. * lines and cols are 1-based. Modified: haiku/trunk/src/bin/open.cpp =================================================================== --- haiku/trunk/src/bin/open.cpp 2008-02-13 22:19:05 UTC (rev 23958) +++ haiku/trunk/src/bin/open.cpp 2008-02-14 22:53:34 UTC (rev 23959) @@ -85,15 +85,17 @@ // try to open it as an URI BString mimeType = "application/x-vnd.Be.URL."; BString arg(*argv); - if (arg.FindFirst("://") >= 0) - mimeType.Append(arg, arg.FindFirst("://")); - else - mimeType.Append(arg, arg.FindFirst(":")); + mimeType.Append(arg, arg.FindFirst(":")); - char *args[2] = { *argv, NULL }; - status = be_roster->Launch(openWith ? openWith : mimeType.String(), 1, args); - if (status == B_OK) - continue; + // the protocol should be alphanum + // we just check if it's registered + // if not there is likely no supporting app anyway + if (BMimeType::IsValid(mimeType.String())) { + char *args[2] = { *argv, NULL }; + status = be_roster->Launch(openWith ? openWith : mimeType.String(), 1, args); + if (status == B_OK) + continue; + } // maybe it's "file:line" or "file:line:col" int line = 0, col = 0, i; @@ -109,7 +111,7 @@ status = entry.SetTo(arg.String()); if (status == B_OK && entry.Exists()) - status = open_file(openWith, entry, line - 1, col - 1); + status = open_file(openWith, entry, line); if (status == B_OK) continue; @@ -121,7 +123,7 @@ status = entry.SetTo(arg.String()); if (status == B_OK && entry.Exists()) - status = open_file(openWith, entry, line - 1, col - 1); + status = open_file(openWith, entry, line, col); } } else status = B_ENTRY_NOT_FOUND; From mmlr at mail.berlios.de Thu Feb 14 23:55:02 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 14 Feb 2008 23:55:02 +0100 Subject: [Haiku-commits] r23960 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200802142255.m1EMt2jU025175@sheep.berlios.de> Author: mmlr Date: 2008-02-14 23:55:02 +0100 (Thu, 14 Feb 2008) New Revision: 23960 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23960&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: Turns out the only thing we didn't do in bfs_free_cookie was - actually free the cookie. One memory leak less... Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2008-02-14 22:53:34 UTC (rev 23959) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2008-02-14 22:55:02 UTC (rev 23960) @@ -1333,6 +1333,7 @@ volume->Allocator().StopChecking(NULL); } + free(cookie); return B_OK; } From mmlr at mail.berlios.de Fri Feb 15 00:16:50 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Fri, 15 Feb 2008 00:16:50 +0100 Subject: [Haiku-commits] r23961 - haiku/trunk/src/system/kernel Message-ID: <200802142316.m1ENGo7H027277@sheep.berlios.de> Author: mmlr Date: 2008-02-15 00:16:50 +0100 (Fri, 15 Feb 2008) New Revision: 23961 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23961&view=rev Modified: haiku/trunk/src/system/kernel/heap.cpp Log: * Add a "stats" argument to the kernel heap leak checker to only print the total count of allocations and bytes. * Also add a few more bin sizes (for 8, 24 and 48 bytes) turns out especially allocations of 20-24 bytes are pretty common. And as it only wastes a few bytes per page this doesn't hurt at all. Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-14 22:55:02 UTC (rev 23960) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-14 23:16:50 UTC (rev 23961) @@ -225,18 +225,18 @@ { team_id team = -1; thread_id thread = -1; - if (argc == 3) { - if (strcmp(argv[1], "team") == 0) - team = strtoul(argv[2], NULL, 0); - else if (strcmp(argv[1], "thread") == 0) - thread = strtoul(argv[2], NULL, 0); + bool statsOnly = false; + for (int32 i = 1; i < argc; i++) { + if (strcmp(argv[i], "team") == 0) + team = strtoul(argv[++i], NULL, 0); + else if (strcmp(argv[i], "thread") == 0) + thread = strtoul(argv[++i], NULL, 0); + else if (strcmp(argv[i], "stats") == 0) + statsOnly = true; else { print_debugger_command_usage(argv[0]); return 0; } - } else if (argc != 1) { - print_debugger_command_usage(argv[0]); - return 0; } size_t totalSize = 0; @@ -275,8 +275,11 @@ || (team == -1 && info->thread == thread) || (thread == -1 && info->team == team)) { // interesting... - dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", - info->team, info->thread, base, info->size); + if (!statsOnly) { + dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", + info->team, info->thread, base, info->size); + } + totalSize += info->size; totalCount++; } @@ -297,8 +300,11 @@ || (team == -1 && info->thread == thread) || (thread == -1 && info->team == team)) { // interesting... - dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", - info->team, info->thread, base, info->size); + if (!statsOnly) { + dprintf("team: % 6ld; thread: % 6ld; address: 0x%08lx; size: %lu bytes\n", + info->team, info->thread, base, info->size); + } + totalSize += info->size; totalCount++; } @@ -439,7 +445,7 @@ base += sizeof(heap_allocator); size -= sizeof(heap_allocator); - size_t binSizes[] = { 16, 32, 64, 96, 128, 192, 256, 384, 512, 1024, 2048, B_PAGE_SIZE }; + size_t binSizes[] = { 8, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 1024, 2048, B_PAGE_SIZE }; uint32 binCount = sizeof(binSizes) / sizeof(binSizes[0]); heap->bin_count = binCount; heap->bins = (heap_bin *)base; @@ -995,11 +1001,13 @@ add_debugger_command("heap", &dump_heap_list, "Dump stats about the kernel heap(s)"); #if KERNEL_HEAP_LEAK_CHECK add_debugger_command_etc("allocations", &dump_allocations, - "Dump current allocations", "[(\"team\" | \"thread\") ]\n" + "Dump current allocations", "[(\"team\" | \"thread\") ] [\"stats\"]\n" "If no parameters are given, all current alloactions are dumped.\n" "If either \"team\" or \"thread\" is specified as the first argument,\n" "only allocations matching the team or thread id given in the second\n" - "argument are printed.\n", 0); + "argument are printed.\n" + "If the optional argument \"stats\" is specified, only the allocation\n" + "counts and no individual allocations are printed\n", 0); #endif return B_OK; } From mmu_man at mail.berlios.de Fri Feb 15 03:38:41 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 15 Feb 2008 03:38:41 +0100 Subject: [Haiku-commits] r23962 - haiku/trunk/src/bin Message-ID: <200802150238.m1F2cfHi026983@sheep.berlios.de> Author: mmu_man Date: 2008-02-15 03:38:39 +0100 (Fri, 15 Feb 2008) New Revision: 23962 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23962&view=rev Modified: haiku/trunk/src/bin/open.cpp Log: Fix Haiku build, sorry ;) Modified: haiku/trunk/src/bin/open.cpp =================================================================== --- haiku/trunk/src/bin/open.cpp 2008-02-14 23:16:50 UTC (rev 23961) +++ haiku/trunk/src/bin/open.cpp 2008-02-15 02:38:39 UTC (rev 23962) @@ -9,6 +9,7 @@ #include #include +#include #include #include From k_lurie at gbrener.org.il Fri Feb 15 11:19:09 2008 From: k_lurie at gbrener.org.il (Kobi Lurie) Date: Fri, 15 Feb 2008 12:19:09 +0200 Subject: [Haiku-commits] =?windows-1255?b?W0Z3ZDog7PTp4yDm6+Xp5fog5ODj7SDk?= =?windows-1255?b?8uXs7ukg7uLp8iDs6fn44Oxd?= Message-ID: <47B5671D.3030101@gbrener.org.il> -------- Original Message -------- Subject: ???? ?????? ???? ?????? ???? ?????? Date: Fri, 15 Feb 2008 03:26:22 +0200 From: Ben Kaminsky Reply-To: benkamin at 013.net To: benkamin at 013.net ???? ?????, ?-18/2 ?????? ???? ????? ?????. ?????? ??????. ???? ???? ??????? ??. ??????? ?????????? ?????'??? ???????? ??????? ??????? ?????. ???? ?????, ????? ???? ????? ???? ????? ??? ??????? ??? ??? ?? ???? ???? ???? ?????. ???? ?? ?????: ????? ?? ?????? ??? ??????? ???????? ???? ???? ???????????. ?????? ?????? ????? ?????, ????? ?????, ????? ?????? ??????? "????? ????" ????? ???? ????? ??????, ????? ????? ????? ?????? ?????? ??????, ????? ???????, ????? ???? ????? ?? ????? ?????? ????? ????? ?????? ?????????, ????? ???? ??? ?????? ????. "???? ?????? ???? ??????" ????? ??? 37 ?????? ?-150 ???? ??? ??????. ?????? ??? ?? ????? ??????? ??????? ?????? ????? ????: "????? ??? ????????? ????? ????? ????? ??? ????? ?? ????? ?????? ???? ??? ????? ?? ???. ????? ????? ????? ??????? ?????? ????? ?? ????? ?????????." ??? ????? ???? ???????? ???? ?????? ?? ???? ?? "????? ?? ???", ?????? ?? ???? ????????? ????? ?? ???????. ???? ???? ????: http://www.halapid.org.il ???? ??? ?? ????? ?????? ?? ????? ?????? ??????. ???? ????? ?? ?? ????. ???? ???, ?? ??????? 052-6212474 -------------- next part -------------- A non-text attachment was scrubbed... Name: lapid-invitation.jpg Type: image/jpeg Size: 109491 bytes Desc: not available URL: From korli at mail.berlios.de Sat Feb 16 14:02:04 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 16 Feb 2008 14:02:04 +0100 Subject: [Haiku-commits] r23963 - in haiku/trunk/src/add-ons/translators: . pcx Message-ID: <200802161302.m1GD24sC000146@sheep.berlios.de> Author: korli Date: 2008-02-16 14:02:03 +0100 (Sat, 16 Feb 2008) New Revision: 23963 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23963&view=rev Added: haiku/trunk/src/add-ons/translators/pcx/ haiku/trunk/src/add-ons/translators/pcx/ConfigView.cpp haiku/trunk/src/add-ons/translators/pcx/ConfigView.h haiku/trunk/src/add-ons/translators/pcx/Jamfile haiku/trunk/src/add-ons/translators/pcx/PCX.cpp haiku/trunk/src/add-ons/translators/pcx/PCX.h haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.cpp haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.h haiku/trunk/src/add-ons/translators/pcx/main.cpp Modified: haiku/trunk/src/add-ons/translators/Jamfile Log: added a PCX translator with some supported formats Modified: haiku/trunk/src/add-ons/translators/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/Jamfile 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/Jamfile 2008-02-16 13:02:03 UTC (rev 23963) @@ -8,6 +8,7 @@ SubInclude HAIKU_TOP src add-ons translators jpeg ; SubInclude HAIKU_TOP src add-ons translators jpeg2000 ; SubInclude HAIKU_TOP src add-ons translators libtiff ; +SubInclude HAIKU_TOP src add-ons translators pcx ; SubInclude HAIKU_TOP src add-ons translators png ; SubInclude HAIKU_TOP src add-ons translators ppm ; SubInclude HAIKU_TOP src add-ons translators raw ; Added: haiku/trunk/src/add-ons/translators/pcx/ConfigView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/ConfigView.cpp 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/ConfigView.cpp 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,57 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "ConfigView.h" +#include "PCXTranslator.h" + +#include +#include + +#include +#include + + +ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) + : BView(frame, "PCXTranslator Settings", resize, flags) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + + font_height fontHeight; + be_bold_font->GetHeight(&fontHeight); + float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + + BRect rect(10, 10, 200, 10 + height); + BStringView *stringView = new BStringView(rect, "title", "PCX Images"); + stringView->SetFont(be_bold_font); + stringView->ResizeToPreferred(); + AddChild(stringView); + + rect.OffsetBy(0, height + 10); + char version[256]; + sprintf(version, "Version %d.%d.%d, %s", + int(B_TRANSLATION_MAJOR_VERSION(PCX_TRANSLATOR_VERSION)), + int(B_TRANSLATION_MINOR_VERSION(PCX_TRANSLATOR_VERSION)), + int(B_TRANSLATION_REVISION_VERSION(PCX_TRANSLATOR_VERSION)), + __DATE__); + stringView = new BStringView(rect, "version", version); + stringView->ResizeToPreferred(); + AddChild(stringView); + + GetFontHeight(&fontHeight); + height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; + + rect.OffsetBy(0, height + 5); + stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); + stringView->ResizeToPreferred(); + AddChild(stringView); +} + + +ConfigView::~ConfigView() +{ +} + Added: haiku/trunk/src/add-ons/translators/pcx/ConfigView.h =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/ConfigView.h 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/ConfigView.h 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,19 @@ +/* + * Copyright 2004-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef CONFIG_VIEW_H +#define CONFIG_VIEW_H + + +#include + + +class ConfigView : public BView { + public: + ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, + uint32 flags = B_WILL_DRAW); + virtual ~ConfigView(); +}; + +#endif /* CONFIG_VIEW_H */ Added: haiku/trunk/src/add-ons/translators/pcx/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/Jamfile 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/Jamfile 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,27 @@ +SubDir HAIKU_TOP src add-ons translators pcx ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +# Include code from shared translator directory +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; + +Translator PCXTranslator : + # PCXTranslator classes + main.cpp + PCXTranslator.cpp + ConfigView.cpp + PCX.cpp + + # shared classes + BaseTranslator.cpp + TranslatorSettings.cpp + TranslatorWindow.cpp + + : be translation + : true +; + +Package haiku-translationkit-cvs : + PCXTranslator + : boot home config add-ons Translators + ; Added: haiku/trunk/src/add-ons/translators/pcx/PCX.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/PCX.cpp 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/PCX.cpp 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,257 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include "PCX.h" +#include "PCXTranslator.h" + +#include + +#include +#include +#include + + +//#define TRACE_PCX +#ifdef TRACE_PCX +# define TRACE(x...) printf(x) +#else +# define TRACE(x...) ; +#endif + + +using namespace PCX; + + +class TempAllocator { + public: + TempAllocator() : fMemory(NULL) {} + ~TempAllocator() { free(fMemory); } + + void *Allocate(size_t size) { return fMemory = malloc(size); } + + private: + void *fMemory; +}; + + +bool +pcx_header::IsValid() const +{ + TRACE("manufacturer:%u version:%u encoding:%u bitsPerPixel:%u nPlanes:%u bytesPerLine:%u\n", manufacturer, version, encoding, bitsPerPixel, nPlanes, bytesPerLine); + return manufacturer == 10 + && version == 5 + && encoding == 1 + && (bitsPerPixel == 1 || bitsPerPixel == 4 || bitsPerPixel == 8) + && (nPlanes == 1 || nPlanes == 3) + && (bitsPerPixel == 8 || nPlanes == 1) + && (bytesPerLine & 1) == 0; +} + + +void +pcx_header::SwapToHost() +{ + swap_data(B_UINT16_TYPE, this, sizeof(pcx_header), B_SWAP_LENDIAN_TO_HOST); +} + + +void +pcx_header::SwapFromHost() +{ + swap_data(B_UINT16_TYPE, this, sizeof(pcx_header), B_SWAP_HOST_TO_LENDIAN); +} + + +// #pragma mark - + + +static status_t +convert_data_to_bits(pcx_header &header, BPositionIO &source, + BPositionIO &target) +{ + uint16 bitsPerPixel = header.bitsPerPixel; + uint16 bytesPerLine = header.bytesPerLine; + uint16 width = header.xMax - header.xMin + 1; + uint16 height = header.yMax - header.yMin + 1; + uint16 nPlanes = header.nPlanes; + uint32 scanLineLength = nPlanes * bytesPerLine; + + // allocate buffers + TempAllocator scanLineAllocator; + TempAllocator paletteAllocator; + uint8 *scanLineData[height]; + uint8 *palette = (uint8 *)paletteAllocator.Allocate(3 * 256); + + for (uint32 row = 0; row < height; row++) { + TRACE("scanline %ld\n", row); + scanLineData[row] = (uint8 *)scanLineAllocator.Allocate(scanLineLength); + if (scanLineData[row] == NULL) + return B_NO_MEMORY; + uint8 *line = scanLineData[row]; + uint32 index = 0; + uint8 x; + do { + if (source.Read(&x, 1) != 1) + return B_IO_ERROR; + if ((x & 0xc0) == 0xc0) { + uint32 count = x & 0x3f; + if (index + count - 1 > scanLineLength) + return B_IO_ERROR; + if (source.Read(&x, 1) != 1) + return B_IO_ERROR; + for (uint32 i = 0; i < count; i++) + line[index++] = x; + } else { + line[index++] = x; + } + } while (index < scanLineLength); + } + + + if (bitsPerPixel == 8 && nPlanes == 1) { + TRACE("palette reading %p 8\n", palette); + uint8 x; + if (source.Read(&x, 1) != 1) + return B_IO_ERROR; + if (x != 12) + return B_IO_ERROR; + if (source.Read(palette, 256 * 3) != 256 * 3) + return B_IO_ERROR; + } else { + TRACE("palette reading %p palette\n", palette); + memcpy(palette, &header.paletteInfo, 48); + } + + uint8 alpha = 255; + if (bitsPerPixel == 1 && nPlanes == 1) { + TRACE("target writing 1\n"); + palette[0] = palette[1] = palette[2] = 0; + palette[3] = palette[4] = palette[5] = 0xff; + for (uint32 row = 0; row < height; row++) { + uint8 *line = scanLineData[row]; + uint8 mask[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; + for (int i = 0; i < width; i++) { + bool isBit = ((line[i >> 3] & mask[i & 7]) != 0) ? true : false; + target.Write(&palette[!isBit ? 2 : 5], 1); + target.Write(&palette[!isBit ? 1 : 4], 1); + target.Write(&palette[!isBit ? 0 : 3], 1); + target.Write(&alpha, 1); + } + } + } else if (bitsPerPixel == 4 && nPlanes == 1) { + TRACE("target writing 4\n"); + for (uint32 row = 0; row < height; row++) { + uint8 *line = scanLineData[row]; + for (int i = 0; i < width; i++) { + uint16 index; + if ((i & 1) == 0) + index = (line[i >> 1] >> 4) & 15; + else + index = line[i >> 1] & 15; + TRACE("target writing 4 i %d index %d\n", i, index); + index += (index + index); + target.Write(&palette[index+2], 1); + target.Write(&palette[index+1], 1); + target.Write(&palette[index], 1); + target.Write(&alpha, 1); + } + } + } else if (bitsPerPixel == 8 && nPlanes == 1) { + TRACE("target writing 8\n"); + for (uint32 row = 0; row < height; row++) { + TRACE("target writing 8 row %ld\n", row); + uint8 *line = scanLineData[row]; + for (int i = 0; i < width; i++) { + uint16 index = line[i]; + index += (index + index); + target.Write(&palette[index+2], 1); + target.Write(&palette[index+1], 1); + target.Write(&palette[index], 1); + target.Write(&alpha, 1); + } + + } + } else { + TRACE("target writing raw\n"); + for (uint32 row = 0; row < height; row++) { + uint8 *line = scanLineData[row]; + for (int i = 0; i < width; i++) { + target.Write(&line[i + 2 * bytesPerLine], 1); + target.Write(&line[i + bytesPerLine], 1); + target.Write(&line[i], 1); + target.Write(&alpha, 1); + } + } + } + + return B_OK; +} + + +// #pragma mark - + + +status_t +PCX::identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel) +{ + // read in the header + + pcx_header header; + if (stream.Read(&header, sizeof(pcx_header)) != (ssize_t)sizeof(pcx_header)) + return B_BAD_VALUE; + + header.SwapToHost(); + + // check header + + if (!header.IsValid()) + return B_BAD_VALUE; + + bitsPerPixel = header.bitsPerPixel; + + TRACE("PCX::identify OK\n"); + + return B_OK; +} + + +/** Converts an PCX image of any type into a B_RGBA32 B_TRANSLATOR_BITMAP. + */ + +status_t +PCX::convert_pcx_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target) +{ + pcx_header header; + if (source.Read(&header, sizeof(pcx_header)) != (ssize_t)sizeof(pcx_header)) + return B_BAD_VALUE; + + header.SwapToHost(); + + // check header + + if (!header.IsValid()) + return B_BAD_VALUE; + + uint16 width = header.xMax - header.xMin + 1; + uint16 height = header.yMax - header.yMin + 1; + + TranslatorBitmap bitsHeader; + bitsHeader.magic = B_TRANSLATOR_BITMAP; + bitsHeader.bounds.left = 0; + bitsHeader.bounds.top = 0; + bitsHeader.bounds.right = width - 1; + bitsHeader.bounds.bottom = height - 1; + bitsHeader.bounds.Set(0, 0, width - 1, height - 1); + bitsHeader.rowBytes = width * 4; + bitsHeader.colors = B_RGB32; + bitsHeader.dataSize = bitsHeader.rowBytes * height; + + // write out Be's Bitmap header + swap_data(B_UINT32_TYPE, &bitsHeader, sizeof(TranslatorBitmap), B_SWAP_HOST_TO_BENDIAN); + target.Write(&bitsHeader, sizeof(TranslatorBitmap)); + + return convert_data_to_bits(header, source, target); +} Added: haiku/trunk/src/add-ons/translators/pcx/PCX.h =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/PCX.h 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/PCX.h 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,58 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef PCX_H +#define PCX_H + + +#include +#include +#include + +class BMessage; + + +namespace PCX { + +struct pcx_header { + uint8 manufacturer; + uint8 version; + uint8 encoding; + uint8 bitsPerPixel; + uint16 xMin, yMin, xMax, yMax; + uint16 hDpi, vDpi; + uint8 colormap[48]; + uint8 reserved; + uint8 nPlanes; + uint16 bytesPerLine; + uint16 paletteInfo; + uint16 hScreenSize, vScreenSize; + uint8 filler[54]; + bool IsValid() const; + void SwapToHost(); + void SwapFromHost(); +} _PACKED; + + +struct rgba32_color { + uint8 blue; + uint8 green; + uint8 red; + uint8 alpha; + + inline bool + operator==(const rgba32_color& other) const + { + return red == other.red && green == other.green && blue == other.blue; + } +}; + + +extern status_t identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel); +extern status_t convert_pcx_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target); + +} // namespace PCX + +#endif /* PCX_H */ Added: haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.cpp 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.cpp 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,174 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "PCXTranslator.h" +#include "ConfigView.h" +#include "PCX.h" + +#include +#include +#include + + +#define kPCXMimeType "image/x-pcx" + + +// The input formats that this translator supports. +translation_format sInputFormats[] = { + { + PCX_IMAGE_FORMAT, + B_TRANSLATOR_BITMAP, + PCX_IN_QUALITY, + PCX_IN_CAPABILITY, + kPCXMimeType, + "PCX image" + }/*, + { + B_TRANSLATOR_BITMAP, + B_TRANSLATOR_BITMAP, + BITS_IN_QUALITY, + BITS_IN_CAPABILITY, + "x-be-bitmap", + "Be Bitmap image" + },*/ +}; + +// The output formats that this translator supports. +translation_format sOutputFormats[] = { + /*{ + PCX_IMAGE_FORMAT, + B_TRANSLATOR_BITMAP, + PCX_OUT_QUALITY, + PCX_OUT_CAPABILITY, + kPCXMimeType, + "PCX image" + },*/ + { + B_TRANSLATOR_BITMAP, + B_TRANSLATOR_BITMAP, + BITS_OUT_QUALITY, + BITS_OUT_CAPABILITY, + "x-be-bitmap", + "Be Bitmap image" + }, +}; + +// Default settings for the Translator +static TranSetting sDefaultSettings[] = { + {B_TRANSLATOR_EXT_HEADER_ONLY, TRAN_SETTING_BOOL, false}, + {B_TRANSLATOR_EXT_DATA_ONLY, TRAN_SETTING_BOOL, false} +}; + +const uint32 kNumInputFormats = sizeof(sInputFormats) / sizeof(translation_format); +const uint32 kNumOutputFormats = sizeof(sOutputFormats) / sizeof(translation_format); +const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting); + + +PCXTranslator::PCXTranslator() + : BaseTranslator("PCX Images", "PCX Translator", + PCX_TRANSLATOR_VERSION, + sInputFormats, kNumInputFormats, + sOutputFormats, kNumOutputFormats, + "PCXTranslator_Settings", + sDefaultSettings, kNumDefaultSettings, + B_TRANSLATOR_BITMAP, PCX_IMAGE_FORMAT) +{ +} + + +PCXTranslator::~PCXTranslator() +{ +} + + +status_t +PCXTranslator::DerivedIdentify(BPositionIO *stream, + const translation_format *format, BMessage *ioExtension, + translator_info *info, uint32 outType) +{ + if (!outType) + outType = B_TRANSLATOR_BITMAP; + if (outType != B_TRANSLATOR_BITMAP && outType != PCX_IMAGE_FORMAT) + return B_NO_TRANSLATOR; + + int32 bitsPerPixel; + uint8 type; + if (PCX::identify(ioExtension, *stream, type, bitsPerPixel) != B_OK) + return B_NO_TRANSLATOR; + + info->type = PCX_IMAGE_FORMAT; + info->group = B_TRANSLATOR_BITMAP; + info->quality = PCX_IN_QUALITY; + info->capability = PCX_IN_CAPABILITY; + snprintf(info->name, sizeof(info->name), "PCX %lu bit image", + bitsPerPixel); + strcpy(info->MIME, kPCXMimeType); + + return B_OK; +} + + +status_t +PCXTranslator::DerivedTranslate(BPositionIO *source, + const translator_info *info, BMessage *ioExtension, + uint32 outType, BPositionIO *target, int32 baseType) +{ + /*if (!outType) + outType = B_TRANSLATOR_BITMAP; + if (outType != B_TRANSLATOR_BITMAP && outType != PCX_IMAGE_FORMAT) + return B_NO_TRANSLATOR;*/ + + switch (baseType) { + /*case 1: + { + if (outType != PCX_IMAGE_FORMAT) + return B_NO_TRANSLATOR; + + // Source is in bits format - this has to be done here, because + // identify_bits_header() is a member of the BaseTranslator class... + TranslatorBitmap bitsHeader; + status_t status = identify_bits_header(source, NULL, &bitsHeader); + if (status != B_OK) + return status; + + return PCX::convert_bits_to_pcx(ioExtension, *source, bitsHeader, *target); + }*/ + + case 0: + { + // source is NOT in bits format + if (outType != B_TRANSLATOR_BITMAP) + return B_NO_TRANSLATOR; + + return PCX::convert_pcx_to_bits(ioExtension, *source, *target); + } + + default: + return B_NO_TRANSLATOR; + } +} + + +BView * +PCXTranslator::NewConfigView(TranslatorSettings *settings) +{ + return new ConfigView(BRect(0, 0, 225, 175)); +} + + +// #pragma mark - + + +BTranslator * +make_nth_translator(int32 n, image_id you, uint32 flags, ...) +{ + if (n != 0) + return NULL; + + return new PCXTranslator(); +} + Added: haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.h =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.h 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/PCXTranslator.h 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,59 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef PCX_TRANSLATOR_H +#define PCX_TRANSLATOR_H + + +#include "BaseTranslator.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define PCX_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(0, 3, 0) +#define PCX_IMAGE_FORMAT 'PCX ' + +#define PCX_IN_QUALITY 0.5 +#define PCX_IN_CAPABILITY 0.5 +#define BITS_IN_QUALITY 1 +#define BITS_IN_CAPABILITY 1 + +#define PCX_OUT_QUALITY 0.8 +#define PCX_OUT_CAPABILITY 0.8 +#define BITS_OUT_QUALITY 1 +#define BITS_OUT_CAPABILITY 0.9 + + +class PCXTranslator : public BaseTranslator { + public: + PCXTranslator(); + + virtual status_t DerivedIdentify(BPositionIO *inSource, + const translation_format *inFormat, BMessage *ioExtension, + translator_info *outInfo, uint32 outType); + + virtual status_t DerivedTranslate(BPositionIO *inSource, + const translator_info *inInfo, BMessage *ioExtension, + uint32 outType, BPositionIO *outDestination, int32 baseType); + + virtual BView *NewConfigView(TranslatorSettings *settings); + + protected: + virtual ~PCXTranslator(); + // this is protected because the object is deleted by the + // Release() function instead of being deleted directly by + // the user + + private: +}; + +#endif /* PCX_TRANSLATOR_H */ Added: haiku/trunk/src/add-ons/translators/pcx/main.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/main.cpp 2008-02-15 02:38:39 UTC (rev 23962) +++ haiku/trunk/src/add-ons/translators/pcx/main.cpp 2008-02-16 13:02:03 UTC (rev 23963) @@ -0,0 +1,28 @@ +/* + * Copyright 2008, J?r?me Duval, korli at users.berlios.de. All rights reserved. + * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "PCXTranslator.h" +#include "PCX.h" + +#include "TranslatorWindow.h" +#include + + +int +main(int /*argc*/, char **/*argv*/) +{ + BApplication app("application/x-vnd.haiku-pcx-translator"); + + status_t result; + result = LaunchTranslatorWindow(new PCXTranslator, "PCX Settings", BRect(0, 0, 225, 175)); + if (result != B_OK) + return 1; + + app.Run(); + return 0; +} + From korli at mail.berlios.de Sat Feb 16 16:54:52 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 16 Feb 2008 16:54:52 +0100 Subject: [Haiku-commits] r23964 - haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid Message-ID: <200802161554.m1GFsqO3017426@sheep.berlios.de> Author: korli Date: 2008-02-16 16:54:51 +0100 (Sat, 16 Feb 2008) New Revision: 23964 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23964&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c Log: publish_devices() can return NULL, ie for Wacom devices which are not handled by usb_hid Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c 2008-02-16 13:02:03 UTC (rev 23963) +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c 2008-02-16 15:54:51 UTC (rev 23964) @@ -1165,7 +1165,6 @@ rebuild_device_names(); gDeviceListChanged = false; } - assert(gDeviceNames != NULL); return (const char **)gDeviceNames; } From korli at mail.berlios.de Sat Feb 16 19:46:41 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 16 Feb 2008 19:46:41 +0100 Subject: [Haiku-commits] r23965 - in haiku/trunk/src: add-ons/kernel/drivers/network/marvell_yukon/dev/msk libs/compat/freebsd_network/compat/sys Message-ID: <200802161846.m1GIkfmU018584@sheep.berlios.de> Author: korli Date: 2008-02-16 19:46:40 +0100 (Sat, 16 Feb 2008) New Revision: 23965 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23965&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h Log: updated marvell_yukon to 1.26 for the source file and 1.11 for the header should help with bug #1787 Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2008-02-16 15:54:51 UTC (rev 23964) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2008-02-16 18:46:40 UTC (rev 23965) @@ -99,7 +99,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.18 2007/07/20 00:25:20 yongari Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.26 2007/12/05 09:41:58 remko Exp $"); #include #include @@ -193,6 +193,8 @@ "Marvell Yukon 88E8036 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8038, "Marvell Yukon 88E8038 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8039, + "Marvell Yukon 88E8039 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4361, "Marvell Yukon 88E8050 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4360, @@ -203,6 +205,8 @@ "Marvell Yukon 88E8055 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4364, "Marvell Yukon 88E8056 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436A, + "Marvell Yukon 88E8058 Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE550SX, "D-Link 550SX Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE560T, @@ -220,7 +224,7 @@ static int mskc_probe(device_t); static int mskc_attach(device_t); static int mskc_detach(device_t); -static void mskc_shutdown(device_t); +static int mskc_shutdown(device_t); static int mskc_setup_rambuffer(struct msk_softc *); static int mskc_suspend(device_t); static int mskc_resume(device_t); @@ -358,6 +362,11 @@ static struct resource_spec msk_irq_spec_msi[] = { { SYS_RES_IRQ, 1, RF_ACTIVE }, + { -1, 0, 0 } +}; + +static struct resource_spec msk_irq_spec_msi2[] = { + { SYS_RES_IRQ, 1, RF_ACTIVE }, { SYS_RES_IRQ, 2, RF_ACTIVE }, { -1, 0, 0 } }; @@ -367,6 +376,9 @@ { struct msk_if_softc *sc_if; + if (phy != PHY_ADDR_MARV) + return (0); + sc_if = device_get_softc(dev); return (msk_phy_readreg(sc_if, phy, reg)); @@ -405,6 +417,9 @@ { struct msk_if_softc *sc_if; + if (phy != PHY_ADDR_MARV) + return (0); + sc_if = device_get_softc(dev); return (msk_phy_writereg(sc_if, phy, reg, val)); @@ -516,17 +531,14 @@ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), gmac); /* Enable PHY interrupt for FIFO underrun/overflow. */ - if (sc->msk_marvell_phy) - msk_phy_writereg(sc_if, PHY_ADDR_MARV, - PHY_MARV_INT_MASK, PHY_M_IS_FIFO_ERROR); + msk_phy_writereg(sc_if, PHY_ADDR_MARV, + PHY_MARV_INT_MASK, PHY_M_IS_FIFO_ERROR); } else { /* * Link state changed to down. * Disable PHY interrupts. */ - if (sc->msk_marvell_phy) - msk_phy_writereg(sc_if, PHY_ADDR_MARV, - PHY_MARV_INT_MASK, 0); + msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0); /* Disable Rx/Tx MAC. */ gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); @@ -916,7 +928,7 @@ error = EINVAL; break; } - if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U && + if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE && ifr->ifr_mtu > MSK_MAX_FRAMELEN) { error = EINVAL; break; @@ -983,6 +995,16 @@ else ifp->if_hwassist &= ~CSUM_TSO; } + if (sc_if->msk_framesize > MSK_MAX_FRAMELEN && + sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { + /* + * In Yukon EC Ultra, TSO & checksum offload is not + * supported for jumbo frame. + */ + ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); + ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); + } + VLAN_CAPABILITIES(ifp); MSK_IF_UNLOCK(sc_if); break; @@ -1018,64 +1040,38 @@ static int mskc_setup_rambuffer(struct msk_softc *sc) { - int totqsize, minqsize; - int avail, next; + int next; int i; uint8_t val; /* Get adapter SRAM size. */ val = CSR_READ_1(sc, B2_E_0); sc->msk_ramsize = (val == 0) ? 128 : val * 4; - if (sc->msk_hw_id == CHIP_ID_YUKON_FE) - sc->msk_ramsize = 4 * 4; if (bootverbose) device_printf(sc->msk_dev, "RAM buffer size : %dKB\n", sc->msk_ramsize); - - totqsize = sc->msk_ramsize * sc->msk_num_port; - minqsize = MSK_MIN_RXQ_SIZE + MSK_MIN_TXQ_SIZE; - if (minqsize > sc->msk_ramsize) - minqsize = sc->msk_ramsize; - - if (minqsize * sc->msk_num_port > totqsize) { - device_printf(sc->msk_dev, - "not enough RAM buffer memory : %d/%dKB\n", - minqsize * sc->msk_num_port, totqsize); - return (ENOSPC); - } - - avail = totqsize; - if (sc->msk_num_port > 1) { - /* - * Divide up the memory evenly so that everyone gets a - * fair share for dual port adapters. - */ - avail = sc->msk_ramsize; - } - - /* Take away the minimum memory for active queues. */ - avail -= minqsize; - /* Rx queue gets the minimum + 80% of the rest. */ - sc->msk_rxqsize = - (avail * MSK_RAM_QUOTA_RX) / 100 + MSK_MIN_RXQ_SIZE; - avail -= (sc->msk_rxqsize - MSK_MIN_RXQ_SIZE); - sc->msk_txqsize = avail + MSK_MIN_TXQ_SIZE; - + /* + * Give receiver 2/3 of memory and round down to the multiple + * of 1024. Tx/Rx RAM buffer size of Yukon II shoud be multiple + * of 1024. + */ + sc->msk_rxqsize = rounddown((sc->msk_ramsize * 1024 * 2) / 3, 1024); + sc->msk_txqsize = (sc->msk_ramsize * 1024) - sc->msk_rxqsize; for (i = 0, next = 0; i < sc->msk_num_port; i++) { sc->msk_rxqstart[i] = next; - sc->msk_rxqend[i] = next + (sc->msk_rxqsize * 1024) - 1; + sc->msk_rxqend[i] = next + sc->msk_rxqsize - 1; next = sc->msk_rxqend[i] + 1; sc->msk_txqstart[i] = next; - sc->msk_txqend[i] = next + (sc->msk_txqsize * 1024) - 1; + sc->msk_txqend[i] = next + sc->msk_txqsize - 1; next = sc->msk_txqend[i] + 1; if (bootverbose) { device_printf(sc->msk_dev, "Port %d : Rx Queue %dKB(0x%08x:0x%08x)\n", i, - sc->msk_rxqsize, sc->msk_rxqstart[i], + sc->msk_rxqsize / 1024, sc->msk_rxqstart[i], sc->msk_rxqend[i]); device_printf(sc->msk_dev, "Port %d : Tx Queue %dKB(0x%08x:0x%08x)\n", i, - sc->msk_txqsize, sc->msk_txqstart[i], + sc->msk_txqsize / 1024, sc->msk_txqstart[i], sc->msk_txqend[i]); } } @@ -1345,7 +1341,8 @@ CSR_WRITE_4(sc, STAT_LIST_ADDR_HI, MSK_ADDR_HI(addr)); /* Set the status list last index. */ CSR_WRITE_2(sc, STAT_LAST_IDX, MSK_STAT_RING_CNT - 1); - if (HW_FEATURE(sc, HWF_WA_DEV_43_418)) { + if (sc->msk_hw_id == CHIP_ID_YUKON_EC && + sc->msk_hw_rev == CHIP_REV_YU_EC_A1) { /* WA for dev. #4.3 */ CSR_WRITE_2(sc, STAT_TX_IDX_TH, ST_TXTH_IDX_MASK); /* WA for dev. #4.18 */ @@ -1354,8 +1351,11 @@ } else { CSR_WRITE_2(sc, STAT_TX_IDX_TH, 0x0a); CSR_WRITE_1(sc, STAT_FIFO_WM, 0x10); - CSR_WRITE_1(sc, STAT_FIFO_ISR_WM, - HW_FEATURE(sc, HWF_WA_DEV_4109) ? 0x10 : 0x04); + if (sc->msk_hw_id == CHIP_ID_YUKON_XL && + sc->msk_hw_rev == CHIP_REV_YU_XL_A0) + CSR_WRITE_1(sc, STAT_FIFO_ISR_WM, 0x04); + else + CSR_WRITE_1(sc, STAT_FIFO_ISR_WM, 0x10); CSR_WRITE_4(sc, STAT_ISR_TIMER_INI, 0x0190); } /* @@ -1453,13 +1453,8 @@ * compute the checksum? I think there is no reason to spend time to * make Rx checksum offload work on Yukon II hardware. */ - ifp->if_capabilities = IFCAP_TXCSUM; - ifp->if_hwassist = MSK_CSUM_FEATURES; - if (sc->msk_hw_id != CHIP_ID_YUKON_EC_U) { - /* It seems Yukon EC Ultra doesn't support TSO. */ - ifp->if_capabilities |= IFCAP_TSO4; - ifp->if_hwassist |= CSUM_TSO; - } + ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_TSO4; + ifp->if_hwassist = MSK_CSUM_FEATURES | CSUM_TSO; ifp->if_capenable = ifp->if_capabilities; ifp->if_ioctl = msk_ioctl; ifp->if_start = msk_start; @@ -1505,6 +1500,9 @@ */ ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); + sc_if->msk_framesize = ifp->if_mtu + ETHER_HDR_LEN + + ETHER_VLAN_ENCAP_LEN; + /* * Do miibus setup. */ @@ -1517,10 +1515,6 @@ error = ENXIO; goto fail; } - /* Check whether PHY Id is MARVELL. */ - if (msk_phy_readreg(sc_if, PHY_ADDR_MARV, PHY_MARV_ID0) - == PHY_MARV_ID0_VAL) - sc->msk_marvell_phy = 1; fail: if (error != 0) { @@ -1540,7 +1534,7 @@ mskc_attach(device_t dev) { struct msk_softc *sc; - int error, msic, *port, reg; + int error, msic, msir, *port, reg; sc = device_get_softc(dev); sc->msk_dev = dev; @@ -1629,74 +1623,20 @@ else sc->msk_bustype = MSK_PCI_BUS; - /* Get H/W features(bugs). */ switch (sc->msk_hw_id) { case CHIP_ID_YUKON_EC: - sc->msk_clock = 125; /* 125 Mhz */ - if (sc->msk_hw_rev == CHIP_REV_YU_EC_A1) { - sc->msk_hw_feature = - HWF_WA_DEV_42 | HWF_WA_DEV_46 | HWF_WA_DEV_43_418 | - HWF_WA_DEV_420 | HWF_WA_DEV_423 | - HWF_WA_DEV_424 | HWF_WA_DEV_425 | HWF_WA_DEV_427 | - HWF_WA_DEV_428 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4152 | HWF_WA_DEV_4167; - } else { - /* A2/A3 */ - sc->msk_hw_feature = - HWF_WA_DEV_424 | HWF_WA_DEV_425 | HWF_WA_DEV_427 | - HWF_WA_DEV_428 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4152 | HWF_WA_DEV_4167; - } - break; case CHIP_ID_YUKON_EC_U: sc->msk_clock = 125; /* 125 Mhz */ - if (sc->msk_hw_rev == CHIP_REV_YU_EC_U_A0) { - sc->msk_hw_feature = HWF_WA_DEV_427 | HWF_WA_DEV_483 | - HWF_WA_DEV_4109; - } else if (sc->msk_hw_rev == CHIP_REV_YU_EC_A1) { - uint16_t v; - - sc->msk_hw_feature = HWF_WA_DEV_427 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4185; - v = CSR_READ_2(sc, Q_ADDR(Q_XA1, Q_WM)); - if (v == 0) - sc->msk_hw_feature |= HWF_WA_DEV_4185CS | - HWF_WA_DEV_4200; - } break; case CHIP_ID_YUKON_FE: sc->msk_clock = 100; /* 100 Mhz */ - sc->msk_hw_feature = HWF_WA_DEV_427 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4152 | HWF_WA_DEV_4167; break; case CHIP_ID_YUKON_XL: sc->msk_clock = 156; /* 156 Mhz */ - switch (sc->msk_hw_rev) { - case CHIP_REV_YU_XL_A0: - sc->msk_hw_feature = - HWF_WA_DEV_427 | HWF_WA_DEV_463 | HWF_WA_DEV_472 | - HWF_WA_DEV_479 | HWF_WA_DEV_483 | HWF_WA_DEV_4115 | - HWF_WA_DEV_4152 | HWF_WA_DEV_4167; - break; - case CHIP_REV_YU_XL_A1: - sc->msk_hw_feature = - HWF_WA_DEV_427 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4115 | HWF_WA_DEV_4152 | HWF_WA_DEV_4167; - break; - case CHIP_REV_YU_XL_A2: - sc->msk_hw_feature = - HWF_WA_DEV_427 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4115 | HWF_WA_DEV_4167; - break; - case CHIP_REV_YU_XL_A3: - sc->msk_hw_feature = - HWF_WA_DEV_427 | HWF_WA_DEV_483 | HWF_WA_DEV_4109 | - HWF_WA_DEV_4115; - } break; default: sc->msk_clock = 156; /* 156 Mhz */ - sc->msk_hw_feature = 0; + break; } /* Allocate IRQ resources. */ @@ -1714,13 +1654,27 @@ */ if (legacy_intr != 0) msi_disable = 1; - if (msic == 2 && msi_disable == 0 && sc->msk_num_port == 1 && - pci_alloc_msi(dev, &msic) == 0) { - if (msic == 2) { - sc->msk_msi = 1; - sc->msk_irq_spec = msk_irq_spec_msi; - } else - pci_release_msi(dev); + if (msi_disable == 0) { + switch (msic) { + case 2: + case 1: /* 88E8058 reports 1 MSI message */ + msir = msic; + if (sc->msk_num_port == 1 && + pci_alloc_msi(dev, &msir) == 0) { + if (msic == msir) { + sc->msk_msi = 1; + sc->msk_irq_spec = msic == 2 ? + msk_irq_spec_msi2 : + msk_irq_spec_msi; + } else + pci_release_msi(dev); + } + break; + default: + device_printf(dev, + "Unexpected number of MSI messages : %d\n", msic); + break; + } } error = bus_alloc_resources(dev, sc->msk_irq_spec, sc->msk_irq); @@ -2964,7 +2918,7 @@ taskqueue_enqueue(taskqueue_fast, &sc_if->msk_tx_task); } -static void +static int mskc_shutdown(device_t dev) { struct msk_softc *sc; @@ -2987,6 +2941,7 @@ CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); MSK_UNLOCK(sc); + return (0); } static int @@ -3226,15 +3181,12 @@ { uint16_t status; - if (sc_if->msk_softc->msk_marvell_phy) { - msk_phy_readreg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_STAT); - status = msk_phy_readreg(sc_if, PHY_ADDR_MARV, - PHY_MARV_INT_STAT); - /* Handle FIFO Underrun/Overflow? */ - if ((status & PHY_M_IS_FIFO_ERROR)) - device_printf(sc_if->msk_if_dev, - "PHY FIFO underrun/overflow.\n"); - } + msk_phy_readreg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_STAT); + status = msk_phy_readreg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_STAT); + /* Handle FIFO Underrun/Overflow? */ + if ((status & PHY_M_IS_FIFO_ERROR)) + device_printf(sc_if->msk_if_dev, + "PHY FIFO underrun/overflow.\n"); } static void @@ -3706,6 +3658,15 @@ sc_if->msk_framesize = ifp->if_mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; + if (sc_if->msk_framesize > MSK_MAX_FRAMELEN && + sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { + /* + * In Yukon EC Ultra, TSO & checksum offload is not + * supported for jumbo frame. + */ + ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); + ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); + } /* * Initialize GMAC first. @@ -3796,9 +3757,6 @@ /* Configure hardware VLAN tag insertion/stripping. */ msk_setvlan(sc_if, ifp); - /* XXX It seems STFW is requried for all cases. */ - CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), TX_STFW_ENA); - if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U) { /* Set Rx Pause threshould. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, RX_GMF_LP_THR), @@ -3807,16 +3765,17 @@ MSK_ECU_ULPP); if (sc_if->msk_framesize > MSK_MAX_FRAMELEN) { /* - * Can't sure the following code is needed as Yukon - * Yukon EC Ultra may not support jumbo frames. - * * Set Tx GMAC FIFO Almost Empty Threshold. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_AE_THR), - MSK_ECU_AE_THR); + MSK_ECU_JUMBO_WM << 16 | MSK_ECU_AE_THR); /* Disable Store & Forward mode for Tx. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_STFW_DIS); + TX_JUMBO_ENA | TX_STFW_DIS); + } else { + /* Enable Store & Forward mode for Tx. */ + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_JUMBO_DIS | TX_STFW_ENA); } } @@ -4035,8 +3994,7 @@ /* Disable all GMAC interrupt. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), 0); /* Disable PHY interrupt. */ - if (sc->msk_marvell_phy) - msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0); + msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0); /* Disable the RAM Interface Arbiter. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, TXA_CTRL), TXA_DIS_ARB); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h 2008-02-16 15:54:51 UTC (rev 23964) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h 2008-02-16 18:46:40 UTC (rev 23965) @@ -93,7 +93,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/*$FreeBSD: src/sys/dev/msk/if_mskreg.h,v 1.6 2007/06/12 10:50:32 yongari Exp $*/ +/*$FreeBSD: src/sys/dev/msk/if_mskreg.h,v 1.11 2007/12/05 09:41:58 remko Exp $*/ /* * SysKonnect PCI vendor ID @@ -130,11 +130,13 @@ #define DEVICEID_MRVL_8035 0x4350 #define DEVICEID_MRVL_8036 0x4351 #define DEVICEID_MRVL_8038 0x4352 +#define DEVICEID_MRVL_8039 0X4353 #define DEVICEID_MRVL_4360 0x4360 #define DEVICEID_MRVL_4361 0x4361 #define DEVICEID_MRVL_4362 0x4362 #define DEVICEID_MRVL_4363 0x4363 #define DEVICEID_MRVL_4364 0x4364 +#define DEVICEID_MRVL_436A 0x436A /* * D-Link gigabit ethernet device ID @@ -836,8 +838,8 @@ #define CHIP_REV_YU_EC_A2 1 /* Chip Rev. for Yukon-EC A2 */ #define CHIP_REV_YU_EC_A3 2 /* Chip Rev. for Yukon-EC A3 */ -#define CHIP_REV_YU_EC_U_A0 0 -#define CHIP_REV_YU_EC_U_A1 1 +#define CHIP_REV_YU_EC_U_A0 1 +#define CHIP_REV_YU_EC_U_A1 2 /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ #define Y2_STATUS_LNK2_INAC BIT_7 /* Status Link 2 inactiv (0 = activ) */ @@ -1082,8 +1084,9 @@ /* Threshold values for Yukon-EC Ultra */ #define MSK_ECU_ULPP 0x0080 /* Upper Pause Threshold (multiples of 8) */ #define MSK_ECU_LLPP 0x0060 /* Lower Pause Threshold (multiples of 8) */ -#define MSK_ECU_AE_THR 0x0180 /* Almost Empty Threshold */ +#define MSK_ECU_AE_THR 0x0070 /* Almost Empty Threshold */ #define MSK_ECU_TXFF_LEV 0x01a0 /* Tx BMU FIFO Level */ +#define MSK_ECU_JUMBO_WM 0x01 #define MSK_BMU_RX_WM 0x600 /* BMU Rx Watermark */ #define MSK_BMU_TX_WM 0x600 /* BMU Tx Watermark */ @@ -1863,6 +1866,8 @@ #define TX_STFW_ENA BIT_30 /* Enable Store & Forward (Yukon-EC Ultra) */ #define TX_VLAN_TAG_ON BIT_25 /* enable VLAN tagging */ #define TX_VLAN_TAG_OFF BIT_24 /* disable VLAN tagging */ +#define TX_JUMBO_ENA BIT_23 /* Enable Jumbo Mode (Yukon-EC Ultra) */ +#define TX_JUMBO_DIS BIT_22 /* Disable Jumbo Mode (Yukon-EC Ultra) */ #define GMF_WSP_TST_ON BIT_18 /* Write Shadow Pointer Test On */ #define GMF_WSP_TST_OFF BIT_17 /* Write Shadow Pointer Test Off */ #define GMF_WSP_STEP BIT_16 /* Write Shadow Pointer Step/Increment */ @@ -2020,35 +2025,6 @@ /* GPHY address (bits 15..11 of SMI control reg) */ #define PHY_ADDR_MARV 0 -/*-RMV- DWORD 1: Deviations */ -#define HWF_WA_DEV_4200 0x10200000UL /*-RMV- 4.200 (D3 Blue Screen)*/ -#define HWF_WA_DEV_4185CS 0x10100000UL /*-RMV- 4.185 (ECU 100 CS cal)*/ -#define HWF_WA_DEV_4185 0x10080000UL /*-RMV- 4.185 (ECU Tx h check)*/ -#define HWF_WA_DEV_4167 0x10040000UL /*-RMV- 4.167 (Rx OvSize Hang)*/ -#define HWF_WA_DEV_4152 0x10020000UL /*-RMV- 4.152 (RSS issue) */ -#define HWF_WA_DEV_4115 0x10010000UL /*-RMV- 4.115 (Rx MAC FIFO) */ -#define HWF_WA_DEV_4109 0x10008000UL /*-RMV- 4.109 (BIU hang) */ -#define HWF_WA_DEV_483 0x10004000UL /*-RMV- 4.83 (Rx TCP wrong) */ -#define HWF_WA_DEV_479 0x10002000UL /*-RMV- 4.79 (Rx BMU hang II) */ -#define HWF_WA_DEV_472 0x10001000UL /*-RMV- 4.72 (GPHY2 MDC clk) */ -#define HWF_WA_DEV_463 0x10000800UL /*-RMV- 4.63 (Rx BMU hang I) */ -#define HWF_WA_DEV_427 0x10000400UL /*-RMV- 4.27 (Tx Done Rep) */ -#define HWF_WA_DEV_42 0x10000200UL /*-RMV- 4.2 (pref unit burst) */ -#define HWF_WA_DEV_46 0x10000100UL /*-RMV- 4.6 (CPU crash II) */ -#define HWF_WA_DEV_43_418 0x10000080UL /*-RMV- 4.3 & 4.18 (PCI unexp */ -/*-RMV- compl&Stat BMU deadl) */ -#define HWF_WA_DEV_420 0x10000040UL /*-RMV- 4.20 (Status BMU ov) */ -#define HWF_WA_DEV_423 0x10000020UL /*-RMV- 4.23 (TCP Segm Hang) */ -#define HWF_WA_DEV_424 0x10000010UL /*-RMV- 4.24 (MAC reg overwr) */ -#define HWF_WA_DEV_425 0x10000008UL /*-RMV- 4.25 (Magic packet */ -/*-RMV- with odd offset) */ -#define HWF_WA_DEV_428 0x10000004UL /*-RMV- 4.28 (Poll-U &BigEndi)*/ -#define HWF_WA_FIFO_FLUSH_YLA0 0x10000002UL /*-RMV- dis Rx GMAC FIFO Flush*/ - -#define HW_FEATURE(sc, f) \ - (((((sc)->msk_hw_feature & 0x30000000) >> 28) & ((f) & 0x0fffffff)) != 0) - - #define MSK_ADDR_LO(x) ((uint64_t) (x) & 0xffffffffUL) #define MSK_ADDR_HI(x) ((uint64_t) (x) >> 32) @@ -2331,9 +2307,7 @@ uint32_t msk_intrmask; uint32_t msk_intrhwemask; int msk_suspended; - int msk_hw_feature; int msk_clock; - int msk_marvell_phy; int msk_msi; struct msk_if_softc *msk_if[2]; device_t msk_devs[2]; Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2008-02-16 15:54:51 UTC (rev 23964) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2008-02-16 18:46:40 UTC (rev 23965) @@ -48,5 +48,6 @@ #define ALIGN(x) ((((unsigned)x) + ALIGN_BYTES) & ~ALIGN_BYTES) #define roundup2(x, y) (((x) + ((y) - 1)) & (~((y) - 1))) +#define rounddown(x, y) (((x) / (y)) * (y)) #endif /* _FBSD_COMPAT_SYS_PARAM_H_ */ From korli at mail.berlios.de Sat Feb 16 20:23:17 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 16 Feb 2008 20:23:17 +0100 Subject: [Haiku-commits] r23966 - haiku/trunk/src/apps/aboutsystem Message-ID: <200802161923.m1GJNH1a021663@sheep.berlios.de> Author: korli Date: 2008-02-16 20:23:17 +0100 (Sat, 16 Feb 2008) New Revision: 23966 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23966&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: added copyright for OpenEXR Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-02-16 18:46:40 UTC (rev 23965) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-02-16 19:23:17 UTC (rev 23966) @@ -566,6 +566,10 @@ "Copyright " B_UTF8_COPYRIGHT " ??? (http://lpsolve.sourceforge.net/)."); + // OpenEXR copyrights + AddCopyrightEntry("OpenEXR", + "Copyright " B_UTF8_COPYRIGHT " 2002-2005, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC."); + // Build a list of installed applications and show their // long version info. Well-behaved apps usually give // copyright info there. From leavengood at mail.berlios.de Sun Feb 17 02:08:29 2008 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sun, 17 Feb 2008 02:08:29 +0100 Subject: [Haiku-commits] r23967 - haiku/trunk/src/add-ons/media/media-add-ons/mixer Message-ID: <200802170108.m1H18Txi019423@sheep.berlios.de> Author: leavengood Date: 2008-02-17 02:08:28 +0100 (Sun, 17 Feb 2008) New Revision: 23967 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23967&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp Log: Adding patch from Juan Sebastian Mu?\195?\177oz Arango to fix bug #1571: This creates a new tab Info to contain the information for the media mixer instead of placing it next to the setup controls. Modified: haiku/trunk/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp 2008-02-16 19:23:17 UTC (rev 23966) +++ haiku/trunk/src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp 2008-02-17 01:08:28 UTC (rev 23967) @@ -1698,7 +1698,9 @@ group->MakeDiscreteParameter(PARAM_ETC(80), B_MEDIA_RAW_AUDIO, "Refuse output format changes", B_ENABLE); group->MakeDiscreteParameter(PARAM_ETC(90), B_MEDIA_RAW_AUDIO, "Refuse input format changes", B_ENABLE); + top = web->MakeGroup("Info"); // top level group group = top->MakeGroup(""); + group->MakeNullParameter(PARAM_ETC(1001), B_MEDIA_RAW_AUDIO, "Info:", B_GENERIC); group->MakeNullParameter(PARAM_ETC(1002), B_MEDIA_RAW_AUDIO, "Haiku audio mixer", B_GENERIC); group->MakeNullParameter(PARAM_ETC(1003), B_MEDIA_RAW_AUDIO, "Version: " VERSION_STRING , B_GENERIC); From korli at mail.berlios.de Sun Feb 17 13:02:27 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 17 Feb 2008 13:02:27 +0100 Subject: [Haiku-commits] r23968 - haiku/trunk/build/jam Message-ID: <200802171202.m1HC2Rml031640@sheep.berlios.de> Author: korli Date: 2008-02-17 13:02:15 +0100 (Sun, 17 Feb 2008) New Revision: 23968 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23968&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added PCXTranslator in the hd image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-17 01:08:28 UTC (rev 23967) +++ haiku/trunk/build/jam/HaikuImage 2008-02-17 12:02:15 UTC (rev 23968) @@ -86,9 +86,9 @@ #$(X86_ONLY)vmware.accelerant ; BEOS_ADD_ONS_TRANSLATORS = BMPTranslator EXRTranslator GIFTranslator JPEGTranslator - JPEG2000Translator TIFFTranslator PNGTranslator PPMTranslator + JPEG2000Translator PCXTranslator PNGTranslator PPMTranslator RAWTranslator RTF-Translator SGITranslator STXTTranslator TGATranslator - WonderBrushTranslator RAWTranslator + TIFFTranslator WonderBrushTranslator ; BEOS_ADD_ONS_MEDIA = mixer.media_addon hmulti_audio.media_addon tone_producer_demo.media_addon From bonefish at mail.berlios.de Sun Feb 17 14:32:09 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:32:09 +0100 Subject: [Haiku-commits] r23969 - haiku/trunk/src/system/kernel/fs Message-ID: <200802171332.m1HDW94o016136@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:32:08 +0100 (Sun, 17 Feb 2008) New Revision: 23969 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23969&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: _user_normalize_path() was broken for symlinks in absolute paths. Fixes #1778. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-17 12:02:15 UTC (rev 23968) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-17 13:32:08 UTC (rev 23969) @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1940,7 +1941,7 @@ return B_BAD_VALUE; if (*path == '\0') return B_ENTRY_NOT_FOUND; - if (vnode == NULL) + if (vnode == NULL || path[0] == '/') return path_to_dir_vnode(path, _vnode, filename, kernel); status_t status = get_dir_path_and_leaf(path, filename); From bonefish at mail.berlios.de Sun Feb 17 14:42:28 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:42:28 +0100 Subject: [Haiku-commits] r23970 - haiku/trunk/src/tools/fs_shell Message-ID: <200802171342.m1HDgS6Y016767@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:42:27 +0100 (Sun, 17 Feb 2008) New Revision: 23970 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23970&view=rev Added: haiku/trunk/src/tools/fs_shell/partition_support.cpp haiku/trunk/src/tools/fs_shell/partition_support.h haiku/trunk/src/tools/fs_shell/stat_priv.h Modified: haiku/trunk/src/tools/fs_shell/Jamfile haiku/trunk/src/tools/fs_shell/fcntl.cpp haiku/trunk/src/tools/fs_shell/fssh.cpp haiku/trunk/src/tools/fs_shell/stat.cpp haiku/trunk/src/tools/fs_shell/uio.cpp haiku/trunk/src/tools/fs_shell/unistd.cpp Log: axeld + bonefish: Added parameters --start-offset and --end-offset to restrict the access of the file system to only that part of the given file. Modified: haiku/trunk/src/tools/fs_shell/Jamfile =================================================================== --- haiku/trunk/src/tools/fs_shell/Jamfile 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/Jamfile 2008-02-17 13:42:27 UTC (rev 23970) @@ -47,6 +47,7 @@ lock.cpp module.cpp node_monitor.cpp + partition_support.cpp path_util.cpp rootfs.cpp sem.cpp Modified: haiku/trunk/src/tools/fs_shell/fcntl.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/fcntl.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/fcntl.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -1,5 +1,5 @@ /* - * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. + * Copyright 2007-2008, Ingo Weinhold, ingo_weinhold at gmx.de. * Distributed under the terms of the MIT License. */ @@ -9,6 +9,7 @@ #include #include "fssh_errno.h" +#include "partition_support.h" #include "stat_util.h" @@ -37,19 +38,23 @@ // Use the _kern_open() defined in libroot on BeOS incompatible systems. // Required for proper attribute emulation support. + int fd; #if __BEOS__ - return open(pathname, to_platform_open_mode(oflags), + fd = open(pathname, to_platform_open_mode(oflags), to_platform_mode(mode)); #else - int fd = _kern_open(-1, pathname, to_platform_open_mode(oflags), + fd = _kern_open(-1, pathname, to_platform_open_mode(oflags), to_platform_mode(mode)); if (fd < 0) { fssh_set_errno(fd); - return -1; + fd = -1; } - return fd; #endif + + restricted_file_opened(fd); + + return fd; } Modified: haiku/trunk/src/tools/fs_shell/fssh.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/fssh.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/fssh.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -27,6 +27,7 @@ #include "fssh_string.h" #include "fssh_type_constants.h" #include "module.h" +#include "partition_support.h" #include "path_util.h" #include "syscalls.h" #include "vfs.h" @@ -1159,8 +1160,11 @@ print_usage(bool error) { fprintf((error ? stderr : stdout), - "Usage: %s [-n] \n" - " %s --initialize [-n] " + "Usage: %s [ --start-offset ]\n" + " [ --end-offset ] [-n] \n" + " %s [ --start-offset ]\n" + " [ --end-offset ]\n" + " --initialize [-n] " "[ ]\n", sArgv[0], sArgv[0] ); @@ -1193,6 +1197,8 @@ const char* device = NULL; const char* volumeName = NULL; const char* initParameters = NULL; + fssh_off_t startOffset = 0; + fssh_off_t endOffset = -1; // eat options int argi = 1; @@ -1204,6 +1210,14 @@ initialize = true; } else if (strcmp(arg, "-n") == 0) { interactive = false; + } else if (strcmp(arg, "--start-offset") == 0) { + if (argi >= argc) + print_usage_and_exit(true); + startOffset = atoll(argv[argi++]); + } else if (strcmp(arg, "--end-offset") == 0) { + if (argi >= argc) + print_usage_and_exit(true); + endOffset = atoll(argv[argi++]); } else { print_usage_and_exit(true); } @@ -1247,6 +1261,11 @@ return error; } + // restrict access if requested + if (startOffset != 0 || endOffset != -1) + add_file_restriction(device, startOffset, endOffset); + + // start the action int result; if (initialize) { Added: haiku/trunk/src/tools/fs_shell/partition_support.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/partition_support.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/partition_support.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -0,0 +1,215 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "compatibility.h" + +#include "partition_support.h" + +#include +#include + +#include + +#include "fssh_errno.h" +#include "fssh_stat.h" +#include "fssh_unistd.h" +#include "stat_priv.h" + + +namespace FSShell { + + +struct FileRestriction { + FileRestriction(fssh_dev_t device, fssh_ino_t node, fssh_off_t startOffset, + fssh_off_t endOffset) + : device(device), + node(node), + startOffset(startOffset), + endOffset(endOffset) + { + } + + fssh_dev_t device; + fssh_ino_t node; + fssh_off_t startOffset; + fssh_off_t endOffset; +}; + + +typedef std::list FileRestrictionList; + +static FileRestrictionList sFileRestrictions; + + +static FileRestriction* +find_file_restriction(fssh_dev_t device, fssh_ino_t node) +{ + for (FileRestrictionList::iterator it = sFileRestrictions.begin(); + it != sFileRestrictions.end(); + ++it) { + FileRestriction* restriction = *it; + if (restriction->device == device && restriction->node == node) + return restriction; + } + + return NULL; +} + + +static FileRestriction* +find_file_restriction(int fd) +{ + struct fssh_stat st; + if (unrestricted_fstat(fd, &st) < 0) + return NULL; + + return find_file_restriction(st.fssh_st_dev, st.fssh_st_ino); +} + + +void +add_file_restriction(const char* fileName, fssh_off_t startOffset, + fssh_off_t endOffset) +{ + struct fssh_stat st; + if (unrestricted_stat(fileName, &st) < 0) + return; + + fssh_dev_t device = st.fssh_st_dev; + fssh_ino_t node = st.fssh_st_ino; + + FileRestriction* restriction = find_file_restriction(device, node); + if (restriction) + return; + + if (endOffset < 0) + endOffset = st.fssh_st_size; + + restriction = new FileRestriction(device, node, startOffset, endOffset); + sFileRestrictions.push_back(restriction); +} + + +void +restricted_file_opened(int fd) +{ + FileRestriction* restriction = find_file_restriction(fd); + if (!restriction) + return; + + lseek(fd, restriction->startOffset, SEEK_SET); +} + + +void +restricted_file_duped(int oldFD, int newFD) +{ +} + + +void +restricted_file_closed(int fd) +{ +} + + +int +restricted_file_restrict_io(int fd, fssh_off_t& pos, fssh_off_t size) +{ + FileRestriction* restriction = find_file_restriction(fd); + if (!restriction) + return 0; + + if (pos < 0) { + pos = lseek(fd, 0, SEEK_CUR); + if (pos < 0) + return -1; + } else + pos += restriction->startOffset; + + if (pos < restriction->startOffset || pos > restriction->endOffset) { + fssh_set_errno(B_BAD_VALUE); + return -1; + } + + fssh_off_t maxSize = restriction->endOffset - pos; + if (size > maxSize) + size = maxSize; + + return 0; +} + + +#include +void +restricted_file_restrict_stat(struct fssh_stat* st) +{ + FileRestriction* restriction = find_file_restriction(st->fssh_st_dev, + st->fssh_st_ino); + if (!restriction) + return; + +printf("restricted_file_restrict_stat(): startOffset: %lld, endOffset: %lld\n", +restriction->startOffset, restriction->endOffset); + st->fssh_st_size = restriction->endOffset - restriction->startOffset; +} + + +static int +to_platform_seek_mode(int fsshWhence) +{ + switch (fsshWhence) { + case FSSH_SEEK_CUR: + return SEEK_CUR; + case FSSH_SEEK_END: + return SEEK_END; + case FSSH_SEEK_SET: + default: + return SEEK_SET; + } +} + + +fssh_off_t +fssh_lseek(int fd, fssh_off_t offset, int whence) +{ + FileRestriction* restriction = find_file_restriction(fd); + if (!restriction) + return lseek(fd, offset, to_platform_seek_mode(whence)); + + fssh_off_t pos; + + switch (whence) { + case FSSH_SEEK_CUR: + { + pos = lseek(fd, 0, SEEK_CUR); + if (pos < 0) + return pos; + pos += offset; + break; + } + case FSSH_SEEK_END: + pos = restriction->endOffset + offset; + break; + case FSSH_SEEK_SET: + default: + pos = restriction->startOffset + offset; + break; + } + + if (pos < restriction->startOffset) { + fssh_set_errno(B_BAD_VALUE); + return -1; + } + + pos = lseek(fd, pos, SEEK_SET); + if (pos >= 0) + pos -= restriction->startOffset; + + return pos; +} + + +} // namespace FSShell Added: haiku/trunk/src/tools/fs_shell/partition_support.h =================================================================== --- haiku/trunk/src/tools/fs_shell/partition_support.h 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/partition_support.h 2008-02-17 13:42:27 UTC (rev 23970) @@ -0,0 +1,29 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _FSSH_PARTITION_SUPPORT_H +#define _FSSH_PARTITION_SUPPORT_H + +#include "fssh_defs.h" +#include "fssh_stat.h" + + +namespace FSShell { + + +void add_file_restriction(const char* fileName, fssh_off_t startOffset, + fssh_off_t endOffset); + +void restricted_file_opened(int fd); +void restricted_file_duped(int oldFD, int newFD); +void restricted_file_closed(int fd); + +int restricted_file_restrict_io(int fd, fssh_off_t& pos, fssh_off_t size); +void restricted_file_restrict_stat(struct fssh_stat* st); + + +} // namespace FSShell + + +#endif // _FSSH_PARTITION_SUPPORT_H Modified: haiku/trunk/src/tools/fs_shell/stat.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/stat.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/stat.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -12,6 +12,8 @@ #include #include "fssh_errno.h" +#include "partition_support.h" +#include "stat_priv.h" #include "stat_util.h" @@ -27,15 +29,8 @@ int -fssh_mkdir(const char *path, fssh_mode_t mode) +FSShell::unrestricted_stat(const char *path, struct fssh_stat *fsshStat) { - return mkdir(path, to_platform_mode(mode)); -} - - -int -fssh_stat(const char *path, struct fssh_stat *fsshStat) -{ struct stat st; // Use the _kern_read_stat() defined in libroot on BeOS incompatible @@ -58,7 +53,7 @@ int -fssh_fstat(int fd, struct fssh_stat *fsshStat) +FSShell::unrestricted_fstat(int fd, struct fssh_stat *fsshStat) { struct stat st; @@ -82,7 +77,7 @@ int -fssh_lstat(const char *path, struct fssh_stat *fsshStat) +FSShell::unrestricted_lstat(const char *path, struct fssh_stat *fsshStat) { struct stat st; @@ -103,3 +98,47 @@ return 0; } + +// #pragma mark - + +int +fssh_mkdir(const char *path, fssh_mode_t mode) +{ + return mkdir(path, to_platform_mode(mode)); +} + + +int +fssh_stat(const char *path, struct fssh_stat *fsshStat) +{ + if (FSShell::unrestricted_stat(path, fsshStat) < 0) + return -1; + + FSShell::restricted_file_restrict_stat(fsshStat); + + return 0; +} + + +int +fssh_fstat(int fd, struct fssh_stat *fsshStat) +{ + if (FSShell::unrestricted_fstat(fd, fsshStat) < 0) + return -1; + + FSShell::restricted_file_restrict_stat(fsshStat); + + return 0; +} + + +int +fssh_lstat(const char *path, struct fssh_stat *fsshStat) +{ + if (FSShell::unrestricted_lstat(path, fsshStat) < 0) + return -1; + + FSShell::restricted_file_restrict_stat(fsshStat); + + return 0; +} Added: haiku/trunk/src/tools/fs_shell/stat_priv.h =================================================================== --- haiku/trunk/src/tools/fs_shell/stat_priv.h 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/stat_priv.h 2008-02-17 13:42:27 UTC (rev 23970) @@ -0,0 +1,20 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _FSSH_STAT_PRIV_H +#define _FSSH_STAT_PRIV_H + +#include "fssh_defs.h" + + +namespace FSShell { + +int unrestricted_stat(const char *path, struct fssh_stat *fsshStat); +int unrestricted_fstat(int fd, struct fssh_stat *fsshStat); +int unrestricted_lstat(const char *path, struct fssh_stat *fsshStat); + +} // namespace FSShell + + +#endif // _FSSH_STAT_PRIV_H Modified: haiku/trunk/src/tools/fs_shell/uio.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/uio.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/uio.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -1,5 +1,5 @@ /* - * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. + * Copyright 2007-2008, Ingo Weinhold, bonefish at cs.tu-berlin.de. * Distributed under the terms of the MIT License. */ @@ -12,7 +12,9 @@ #include #include +#include "partition_support.h" + static const fssh_size_t kMaxIOVecs = 1024; @@ -41,6 +43,11 @@ if (!prepare_iovecs(vector, count, systemVecs)) return -1; + fssh_off_t pos = -1; + fssh_size_t length = 0; + if (FSShell::restricted_file_restrict_io(fd, pos, length) < 0) + return -1; + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) return readv(fd, systemVecs, count); #else @@ -57,6 +64,10 @@ if (!prepare_iovecs(vec, count, systemVecs)) return -1; + fssh_size_t length = 0; + if (FSShell::restricted_file_restrict_io(fd, pos, length) < 0) + return -1; + return readv_pos(fd, pos, systemVecs, count); } @@ -68,6 +79,11 @@ if (!prepare_iovecs(vector, count, systemVecs)) return -1; + fssh_off_t pos = -1; + fssh_size_t length = 0; + if (FSShell::restricted_file_restrict_io(fd, pos, length) < 0) + return -1; + #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) return writev(fd, systemVecs, count); #else @@ -84,5 +100,9 @@ if (!prepare_iovecs(vec, count, systemVecs)) return -1; + fssh_size_t length = 0; + if (FSShell::restricted_file_restrict_io(fd, pos, length) < 0) + return -1; + return writev_pos(fd, pos, systemVecs, count); } Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-17 13:32:08 UTC (rev 23969) +++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-17 13:42:27 UTC (rev 23970) @@ -1,5 +1,5 @@ /* - * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. + * Copyright 2007-2008, Ingo Weinhold, ingo_weinhold at gmx.de. * Distributed under the terms of the MIT License. */ @@ -15,6 +15,7 @@ #include "fssh_drivers.h" #include "fssh_errno.h" +#include "partition_support.h" #ifdef __BEOS__ # include @@ -86,22 +87,28 @@ { // Use the _kern_dup() defined in libroot on BeOS incompatible systems. // Required for proper attribute emulation support. + int newFD; #if __BEOS__ - return dup(fd); + newFD = dup(fd); #else - int result = _kern_dup(fd); - if (result < 0) { - fssh_set_errno(result); - return -1; + newFD = _kern_dup(fd); + if (newFD < 0) { + fssh_set_errno(newFD); + newFD = -1; } - return result; #endif + + FSShell::restricted_file_duped(fd, newFD); + + return newFD; } int fssh_close(int fd) { + FSShell::restricted_file_closed(fd); + // Use the _kern_close() defined in libroot on BeOS incompatible systems. // Required for proper attribute emulation support. #if __BEOS__ @@ -296,9 +303,16 @@ fssh_read(int fd, void *buffer, fssh_size_t count) { #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + fssh_off_t pos = -1; + if (FSShell::restricted_file_restrict_io(fd, pos, count) < 0) + return -1; return read(fd, buffer, count); #else - return read_pos(fd, lseek(fd, 0, SEEK_CUR), buffer, count); + fssh_ssize_t bytesRead = read_pos(fd, fssh_lseek(fd, 0, FSSH_SEEK_CUR), + buffer, count); + if (bytesRead > 0) + fssh_lseek(fd, bytesRead, FSSH_SEEK_CUR); + return bytesRead; #endif } @@ -306,6 +320,8 @@ fssh_ssize_t fssh_read_pos(int fd, fssh_off_t pos, void *buffer, fssh_size_t count) { + if (FSShell::restricted_file_restrict_io(fd, pos, count) < 0) + return -1; return read_pos(fd, pos, buffer, count); } @@ -314,20 +330,33 @@ fssh_write(int fd, const void *buffer, fssh_size_t count) { #if !defined(HAIKU_HOST_PLATFORM_FREEBSD) + fssh_off_t pos = -1; + if (FSShell::restricted_file_restrict_io(fd, pos, count) < 0) + return -1; return write(fd, buffer, count); #else - return write_pos(fd, lseek(fd, 0, SEEK_CUR), buffer, count); + fssh_ssize_t written = write_pos(fd, fssh_lseek(fd, 0, FSSH_SEEK_CUR), + buffer, count); + if (written > 0) + fssh_lseek(fd, written, FSSH_SEEK_CUR); + return written; #endif } +#include fssh_ssize_t fssh_write_pos(int fd, fssh_off_t pos, const void *buffer, fssh_size_t count) { + if (FSShell::restricted_file_restrict_io(fd, pos, count) < 0) + return -1; return write_pos(fd, pos, buffer, count); } +// fssh_lseek() -- implemented in partition_support.cpp + + fssh_gid_t fssh_getegid(void) { From bonefish at mail.berlios.de Sun Feb 17 14:45:47 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:45:47 +0100 Subject: [Haiku-commits] r23971 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200802171345.m1HDjlYK017032@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:45:47 +0100 (Sun, 17 Feb 2008) New Revision: 23971 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23971&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: axeld + bonefish: Added parameter --start-offset to allow writing the boot code not only at the beginning of the given file. Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-02-17 13:42:27 UTC (rev 23970) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-02-17 13:45:47 UTC (rev 23971) @@ -161,15 +161,12 @@ // write_boot_code_part static void -write_boot_code_part(const char *fileName, int fd, const uint8 *bootCodeData, - int offset, int size, bool dryRun) +write_boot_code_part(const char *fileName, int fd, off_t imageOffset, + const uint8 *bootCodeData, int offset, int size, bool dryRun) { - printf("writing %d bytes at offset %d%s\n", size, offset, - (dryRun ? " (dry run)" : "")); - if (!dryRun) { - ssize_t bytesWritten = write_pos(fd, offset, bootCodeData + offset, - size); + ssize_t bytesWritten = write_pos(fd, imageOffset + offset, + bootCodeData + offset, size); if (bytesWritten != size) { fprintf(stderr, "Error: Failed to write to \"%s\": %s\n", fileName, strerror(bytesWritten < 0 ? errno : B_ERROR)); @@ -192,6 +189,7 @@ const char **files = new const char*[argc]; int fileCount = 0; bool dryRun = false; + off_t startOffset = 0; // parse arguments for (int argi = 1; argi < argc;) { @@ -206,6 +204,10 @@ // ignore } else if (strcmp(arg, "-full") == 0) { // ignore + } else if (strcmp(arg, "--start-offset") == 0) { + if (argi >= argc) + print_usage_and_exit(true); + startOffset = strtoll(argv[argi++], NULL, 0); } else if (strcmp(arg, "-safe") == 0) { fprintf(stderr, "Error: Sorry, BeOS R3 isn't supported!\n"); exit(1); @@ -498,10 +500,11 @@ printf("Writing boot code to \"%s\" (partition offset: %lld bytes) " "...\n", fileName, partitionOffset); - write_boot_code_part(fileName, fd, bootCodeData, 0, + write_boot_code_part(fileName, fd, startOffset, bootCodeData, 0, kFirstBootCodePartSize, dryRun); - write_boot_code_part(fileName, fd, bootCodeData, - kSecondBootcodePartOffset, kSecondBootcodePartSize, dryRun); + write_boot_code_part(fileName, fd, startOffset, bootCodeData, + kSecondBootcodePartOffset, kSecondBootcodePartSize, + dryRun); close(fd); } From bonefish at mail.berlios.de Sun Feb 17 14:54:33 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:54:33 +0100 Subject: [Haiku-commits] r23972 - in haiku/trunk/build: jam scripts Message-ID: <200802171354.m1HDsXaQ017665@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:54:32 +0100 (Sun, 17 Feb 2008) New Revision: 23972 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23972&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/scripts/build_haiku_image Log: axeld + bonefish: Changed the way the VMware image is built. Instead of creating a normal image first and then adding vmdk header and that image, we create the VMware image in one go, now. Therefore "jam update-vmware-image ..." does now actually update the VMware image directly, instead of updating the normal image and recreating the VMware image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-17 13:45:47 UTC (rev 23971) +++ haiku/trunk/build/jam/HaikuImage 2008-02-17 13:54:32 UTC (rev 23972) @@ -588,10 +588,7 @@ AddTargetVariableToScript $(script) : rc ; AddTargetVariableToScript $(script) : resattr ; AddTargetVariableToScript $(script) : unzip ; -#AddTargetVariableToScript $(script) : $(HAIKU_IMAGE) : imagePath ; - # causes a cyclic dependency -AddVariableToScript $(script) : imagePath - : [ FDirName $(HAIKU_IMAGE_DIR) $(HAIKU_IMAGE_NAME) ] ; +AddTargetVariableToScript $(script) : vmdkheader ; AddVariableToScript $(script) : sourceDirsToCopy : $(HAIKU_INSTALL_SOURCE_DIRS) ; @@ -607,12 +604,10 @@ CreateHaikuImageUnzipFilesScript $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) ; # Convenience wrapper rule around BuildHaikuImage. -rule _BuildHaikuImage +rule _BuildHaikuImage image : isImage : isVMwareImage { - # _BuildHaikuImage : ; + # _BuildHaikuImage : : ; # - local image = $(1) ; - local isImage = $(2) ; # build the image # HAIKU_IMAGE_EARLY_USER_SCRIPTS, HAIKU_IMAGE_LATE_USER_SCRIPTS can be @@ -625,6 +620,7 @@ $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) $(HAIKU_IMAGE_LATE_USER_SCRIPTS) : $(isImage) + : $(isVMwareImage) ; # remove the scripts we have generated @@ -641,18 +637,17 @@ NotFile haiku-image ; Depends haiku-image : $(HAIKU_IMAGE) ; + # install Haiku into a directory NotFile install-haiku ; _BuildHaikuImage install-haiku : 0 ; -#pragma mark - Build The VMWare Image - +# build the VMware image HAIKU_VMWARE_IMAGE_NAME ?= haiku.vmdk ; HAIKU_VMWARE_IMAGE ?= $(HAIKU_VMWARE_IMAGE_NAME) ; MakeLocate $(HAIKU_VMWARE_IMAGE) : $(HAIKU_IMAGE_DIR) ; -BuildVMWareImage $(HAIKU_VMWARE_IMAGE) : $(HAIKU_IMAGE) - : $(HAIKU_IMAGE_SIZE) ; +_BuildHaikuImage $(HAIKU_VMWARE_IMAGE) : true : true ; NotFile haiku-vmware-image ; Depends haiku-vmware-image : $(HAIKU_VMWARE_IMAGE) ; Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2008-02-17 13:45:47 UTC (rev 23971) +++ haiku/trunk/build/jam/ImageRules 2008-02-17 13:54:32 UTC (rev 23972) @@ -624,9 +624,9 @@ CreateContainerUnzipFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ; } -rule BuildHaikuImage haikuImage : scripts : isImage +rule BuildHaikuImage haikuImage : scripts : isImage : isVMwareImage { - # BuildHaikuImage : : ; + # BuildHaikuImage : : : ; if $(isImage) = 1 || $(isImage) = true { IS_IMAGE on $(haikuImage) = 1 ; @@ -634,6 +634,12 @@ IS_IMAGE on $(haikuImage) = "" ; } + if $(isVMwareImage) = 1 || $(isVMwareImage) = true { + IS_VMWARE_IMAGE on $(haikuImage) = 1 ; + } else { + IS_VMWARE_IMAGE on $(haikuImage) = "" ; + } + local mainScript = build_haiku_image ; SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; @@ -643,7 +649,9 @@ actions BuildHaikuImage1 { + export imagePath="$(1)" export isImage="$(IS_IMAGE)" + export isVMwareImage="$(IS_VMWARE_IMAGE)" $(2[1]) $(2[2-]) } Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2008-02-17 13:45:47 UTC (rev 23971) +++ haiku/trunk/build/scripts/build_haiku_image 2008-02-17 13:54:32 UTC (rev 23972) @@ -12,6 +12,7 @@ # sourceDirsToCopy # updateOnly # dontClearImage +# isVMwareImage # # bfsShell # copyattr @@ -20,6 +21,7 @@ # resattr # rc # unzip +# vmdkheader # if [ $# -gt 0 ]; then . $1 @@ -93,15 +95,30 @@ # create the image and mount it if [ $isImage ]; then echo + + imageOffsetFlags= + if [ $isVMwareImage ]; then + imageOffsetFlags="--start-offset 65536" + fi + if [ ! $updateOnly ]; then echo "Creating image ..." + + ddFlags= + if [ $isVMwareImage ]; then + rm -f $imagePath + $vmdkheader -h 64k -i${imageSize}M $imagePath || exit 1 + ddFlags="conv=notrunc oflag=append" + dontClearImage= + fi + if [ ! -e $imagePath -o ! "$dontClearImage" ]; then - dd if=/dev/zero of=$imagePath bs=1048576 count=$imageSize + dd if=/dev/zero of=$imagePath bs=1048576 count=$imageSize $ddFlags fi - $bfsShell --initialize $imagePath Haiku - $makebootable $imagePath + $bfsShell --initialize $imageOffsetFlags $imagePath Haiku + $makebootable $imageOffsetFlags $imagePath fi - $bfsShell -n $imagePath > /dev/null & + $bfsShell -n $imageOffsetFlags $imagePath > /dev/null & sleep 1 fi From bonefish at mail.berlios.de Sun Feb 17 14:57:36 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:57:36 +0100 Subject: [Haiku-commits] r23973 - haiku/trunk/src/system/libroot/os Message-ID: <200802171357.m1HDvaiR017933@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:57:36 +0100 (Sun, 17 Feb 2008) New Revision: 23973 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23973&view=rev Modified: haiku/trunk/src/system/libroot/os/find_directory.c Log: axeld + bonefish: Removed the "config" subdirectory in the /boot/common directory structure. Modified: haiku/trunk/src/system/libroot/os/find_directory.c =================================================================== --- haiku/trunk/src/system/libroot/os/find_directory.c 2008-02-17 13:54:32 UTC (rev 23972) +++ haiku/trunk/src/system/libroot/os/find_directory.c 2008-02-17 13:57:36 UTC (rev 23973) @@ -60,24 +60,24 @@ static const char *common_dirs[] = { COMMON "", // B_COMMON_DIRECTORY - COMMON "/config", // B_COMMON_SYSTEM_DIRECTORY - COMMON "/config/add-ons", - COMMON "/config/boot", - COMMON "/config/fonts", - COMMON "/config/lib", - COMMON "/config/servers", - COMMON "/config/bin", - COMMON "/config/etc", - COMMON "/config/documentation", - COMMON "/config/settings", + COMMON "", // B_COMMON_SYSTEM_DIRECTORY + COMMON "/add-ons", + COMMON "/boot", + COMMON "/fonts", + COMMON "/lib", + COMMON "/servers", + COMMON "/bin", + COMMON "/etc", + COMMON "/documentation", + COMMON "/settings", "develop", // B_COMMON_DEVELOP_DIRECTORY "var/log", // B_COMMON_LOG_DIRECTORY "var/spool", // B_COMMON_SPOOL_DIRECTORY "var/tmp", // B_COMMON_TEMP_DIRECTORY "var", // B_COMMON_VAR_DIRECTORY - COMMON "/config/add-ons/Translators", - COMMON "/config/add-ons/media", - COMMON "/config/sounds", + COMMON "/add-ons/Translators", + COMMON "/add-ons/media", + COMMON "/sounds", }; /* User directories */ From bonefish at mail.berlios.de Sun Feb 17 14:59:29 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 14:59:29 +0100 Subject: [Haiku-commits] r23974 - in haiku/trunk: data/system/boot src/system/runtime_loader Message-ID: <200802171359.m1HDxTH6018107@sheep.berlios.de> Author: bonefish Date: 2008-02-17 14:59:29 +0100 (Sun, 17 Feb 2008) New Revision: 23974 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23974&view=rev Modified: haiku/trunk/data/system/boot/SetupEnvironment haiku/trunk/src/system/runtime_loader/runtime_loader.c Log: axeld + bonefish: Adjusted PATH, LIBRARY_PATH, and the paths built into the runtime loader to included the /boot/common tree. Modified: haiku/trunk/data/system/boot/SetupEnvironment =================================================================== --- haiku/trunk/data/system/boot/SetupEnvironment 2008-02-17 13:57:36 UTC (rev 23973) +++ haiku/trunk/data/system/boot/SetupEnvironment 2008-02-17 13:59:29 UTC (rev 23974) @@ -44,12 +44,12 @@ if [ "$SAFEMODE" != "yes" ] then - export PATH=.:$HOME/config/bin:/bin:/boot/apps:/boot/preferences:/boot/beos/apps:/boot/beos/preferences:$BETOOLS - export LIBRARY_PATH="%A/lib:$HOME/config/lib:/boot/beos/system/lib" + export PATH=.:$HOME/config/bin:/boot/common/bin:/bin:/boot/apps:/boot/preferences:/boot/beos/apps:/boot/beos/preferences:$BETOOLS + export LIBRARY_PATH="%A/lib:$HOME/config/lib:/boot/common/lib:/boot/beos/system/lib" export ADDON_PATH="%A/add-ons:$HOME/config/add-ons:/boot/beos/system/add-ons" else - export PATH=.:/bin:/boot/apps:/boot/preferences:/boot/beos/apps:/boot/beos/preferences:$BETOOLS - export LIBRARY_PATH="%A/lib:/boot/beos/system/lib" + export PATH=.:/boot/common/bin:/bin:/boot/apps:/boot/preferences:/boot/beos/apps:/boot/beos/preferences:$BETOOLS + export LIBRARY_PATH="%A/lib:/boot/common/lib:/boot/beos/system/lib" export ADDON_PATH="%A/add-ons:/boot/beos/system/add-ons" fi Modified: haiku/trunk/src/system/runtime_loader/runtime_loader.c =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-02-17 13:57:36 UTC (rev 23973) +++ haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-02-17 13:59:29 UTC (rev 23974) @@ -59,18 +59,20 @@ switch (type) { case B_APP_IMAGE: - return "/bin:" - "/boot/apps:" - "/boot/preferences:" - "/boot/beos/apps:" - "/boot/beos/preferences:" - "/boot/develop/tools/gnupro/bin"; + return "/boot/common/bin" + ":/bin" + ":/boot/apps" + ":/boot/preferences" + ":/boot/beos/apps" + ":/boot/beos/preferences" + ":/boot/develop/tools/gnupro/bin"; case B_LIBRARY_IMAGE: - return "%A/lib:/boot/beos/system/lib"; + return "%A/lib:/boot/common/lib:/boot/beos/system/lib"; case B_ADD_ON_IMAGE: return "%A/add-ons" + ":/boot/common/add-ons" ":/boot/beos/system/add-ons"; default: From bonefish at mail.berlios.de Sun Feb 17 15:12:02 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 15:12:02 +0100 Subject: [Haiku-commits] r23975 - haiku/trunk/src/system/libroot/os Message-ID: <200802171412.m1HEC2kv018690@sheep.berlios.de> Author: bonefish Date: 2008-02-17 15:12:02 +0100 (Sun, 17 Feb 2008) New Revision: 23975 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23975&view=rev Modified: haiku/trunk/src/system/libroot/os/thread.c Log: axeld + bonefish: BeOS R5's glue code incorrectly calls _thread_do_exit_notification() when main() returns, while Haiku does that in exit(). Therefore when terminating this way the exit hooks were called twice for executables built under BeOS R5. This caused e.g. NetPositive or the R5 svn to crash on exit (our network code actually uses those hooks). Fixes bug #1742. Modified: haiku/trunk/src/system/libroot/os/thread.c =================================================================== --- haiku/trunk/src/system/libroot/os/thread.c 2008-02-17 13:59:29 UTC (rev 23974) +++ haiku/trunk/src/system/libroot/os/thread.c 2008-02-17 14:12:02 UTC (rev 23975) @@ -113,6 +113,8 @@ node = next; } + + tls_set(TLS_ON_EXIT_THREAD_SLOT, NULL); } From bonefish at mail.berlios.de Sun Feb 17 15:34:34 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 15:34:34 +0100 Subject: [Haiku-commits] r23976 - haiku/trunk/src/system/kernel/fs Message-ID: <200802171434.m1HEYYSd022078@sheep.berlios.de> Author: bonefish Date: 2008-02-17 15:34:34 +0100 (Sun, 17 Feb 2008) New Revision: 23976 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23976&view=rev Modified: haiku/trunk/src/system/kernel/fs/pipefs.cpp Log: axeld + bonefish: The return value of Inode::WaitForRequest() is status_t not bool. So the method would always fail when it actually succeeded. This affected reads from pipes which didn't have data. The bug was hidded since VFS code mostly checks error codes only against < B_OK, so that such a read would be treated as 0 byte read. Modified: haiku/trunk/src/system/kernel/fs/pipefs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/pipefs.cpp 2008-02-17 14:12:02 UTC (rev 23975) +++ haiku/trunk/src/system/kernel/fs/pipefs.cpp 2008-02-17 14:34:34 UTC (rev 23976) @@ -760,7 +760,7 @@ // unpublish the condition variable conditionVariable.Unpublish(); - return status != B_OK; + return status; } From kirilla at mail.berlios.de Sun Feb 17 15:36:02 2008 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Sun, 17 Feb 2008 15:36:02 +0100 Subject: [Haiku-commits] r23977 - haiku/trunk/src/apps/mail Message-ID: <200802171436.m1HEa2fx022126@sheep.berlios.de> Author: kirilla Date: 2008-02-17 15:36:01 +0100 (Sun, 17 Feb 2008) New Revision: 23977 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23977&view=rev Modified: haiku/trunk/src/apps/mail/MailWindow.cpp Log: 0L constant typo? Remove menu item before deleting it. Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-17 14:34:34 UTC (rev 23976) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-17 14:36:01 UTC (rev 23977) @@ -2934,8 +2934,10 @@ void TMailWindow::_RebuildQueryMenu(bool firstTime) { - while (BMenuItem* item = fQueryMenu->ItemAt(0L)) + while (fQueryMenu->ItemAt(0)) { + BMenuItem* item = fQueryMenu->RemoveItem((int32)0); delete item; + } fQueryMenu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE("Edit Queries...","???..."), new BMessage(M_EDIT_QUERIES), 'E', B_SHIFT_KEY)); From bonefish at mail.berlios.de Sun Feb 17 15:36:04 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 15:36:04 +0100 Subject: [Haiku-commits] r23978 - haiku/trunk/src/system/kernel/debug Message-ID: <200802171436.m1HEa4l1022162@sheep.berlios.de> Author: bonefish Date: 2008-02-17 15:36:03 +0100 (Sun, 17 Feb 2008) New Revision: 23978 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23978&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.cpp Log: Added "error" debugger command to print the error string for a given numeric error code. Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-17 14:36:01 UTC (rev 23977) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-17 14:36:03 UTC (rev 23978) @@ -687,6 +687,21 @@ } +static int +cmd_error(int argc, char **argv) +{ + if (argc != 2) { + print_debugger_command_usage(argv[0]); + return 0; + } + + int32 error = parse_expression(argv[1]); + kprintf("error 0x%lx: %s\n", error, strerror(error)); + + return 0; +} + + static status_t syslog_sender(void *data) { @@ -964,6 +979,12 @@ "\n" "Evaluates the given expression and prints the result.\n", B_KDEBUG_DONT_PARSE_ARGUMENTS); + add_debugger_command_etc("error", &cmd_error, + "Prints a human-readable description for an error code", + "\n" + "Prints a human-readable description for the given numeric error\n" + "code.\n" + " - The numeric error code.\n", 0); debug_variables_init(); frame_buffer_console_init(args); From bonefish at mail.berlios.de Sun Feb 17 15:36:47 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 15:36:47 +0100 Subject: [Haiku-commits] r23979 - haiku/trunk/src/system/kernel/debug Message-ID: <200802171436.m1HEal8u022224@sheep.berlios.de> Author: bonefish Date: 2008-02-17 15:36:47 +0100 (Sun, 17 Feb 2008) New Revision: 23979 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23979&view=rev Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp Log: axeld + bonefish: Make ktrace_printf() available in the kernel, too. Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-17 14:36:03 UTC (rev 23978) +++ haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-02-17 14:36:47 UTC (rev 23979) @@ -341,6 +341,25 @@ #if ENABLE_TRACING +class KernelTraceEntry : public AbstractTraceEntry { + public: + KernelTraceEntry(const char* message) + { + fMessage = alloc_tracing_buffer_strcpy(message, 256, false); + + Initialized(); + } + + virtual void AddDump(TraceOutput& out) + { + out.Print("kern: %s", fMessage); + } + + private: + char* fMessage; +}; + + class UserTraceEntry : public AbstractTraceEntry { public: UserTraceEntry(const char* message) @@ -1088,6 +1107,23 @@ void +ktrace_printf(const char *format, ...) +{ +#if ENABLE_TRACING + va_list list; + va_start(list, format); + + char buffer[256]; + vsnprintf(buffer, sizeof(buffer), format, list); + + va_end(list); + + new(nothrow) KernelTraceEntry(buffer); +#endif // ENABLE_TRACING +} + + +void _user_ktrace_output(const char *message) { #if ENABLE_TRACING From bonefish at mail.berlios.de Sun Feb 17 15:38:25 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 15:38:25 +0100 Subject: [Haiku-commits] r23980 - haiku/trunk/src/system/kernel Message-ID: <200802171438.m1HEcPAW022355@sheep.berlios.de> Author: bonefish Date: 2008-02-17 15:38:23 +0100 (Sun, 17 Feb 2008) New Revision: 23980 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23980&view=rev Modified: haiku/trunk/src/system/kernel/condition_variable.cpp Log: axeld + bonefish: Before starting to wait on a condition variable check for pending signals first, if the call is interruptable. Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2008-02-17 14:36:47 UTC (rev 23979) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2008-02-17 14:38:23 UTC (rev 23980) @@ -156,8 +156,16 @@ entry = entry->fThreadNext; } - // all entries are unnotified -- wait + // When interruptable, check pending signals first struct thread* thread = thread_get_current_thread(); + if (((flags & B_CAN_INTERRUPT) + && (thread->sig_pending & ~thread->sig_block_mask) != 0) + || ((flags & B_KILL_CAN_INTERRUPT) + && (thread->sig_pending & KILL_SIGNALS))) { + return B_INTERRUPTED; + } + + // wait thread->next_state = B_THREAD_WAITING; thread->condition_variable_entry = firstEntry; thread->sem.blocking = -1; From marcusoverhagen at mail.berlios.de Sun Feb 17 15:44:34 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 17 Feb 2008 15:44:34 +0100 Subject: [Haiku-commits] r23981 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200802171444.m1HEiYDn022744@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-17 15:44:33 +0100 (Sun, 17 Feb 2008) New Revision: 23981 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23981&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h Log: Reuse virtual bus numbers when a mapping already exists. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-02-17 14:38:23 UTC (rev 23980) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-02-17 14:44:33 UTC (rev 23981) @@ -381,13 +381,17 @@ uint16 value = domain << 8 | bus; - // XXX iterate through entries 0 to fNextVirtualBus - // XXX and check if value is already present, return - // XXX key if found instead of inserting a new one + for (VirtualBusMap::Iterator it = fVirtualBusMap.Begin(); it != fVirtualBusMap.End(); ++it) { + if (it->Value() == value) { + *virtualBus = it->Key(); + FLOW("PCI::CreateVirtualBus: domain %d, bus %d already in map => virtualBus %d\n", domain, bus, *virtualBus); + return B_OK; + } + } *virtualBus = fNextVirtualBus++; - dprintf("CreateVirtualBus domain %d, bus %d => virtualBus %d\n", domain, bus, *virtualBus); + FLOW("PCI::CreateVirtualBus: domain %d, bus %d => virtualBus %d\n", domain, bus, *virtualBus); return fVirtualBusMap.Insert(*virtualBus, value); Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-02-17 14:38:23 UTC (rev 23980) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-02-17 14:44:33 UTC (rev 23981) @@ -119,7 +119,9 @@ int fDomainCount; bool fBusEnumeration; - VectorMap fVirtualBusMap; + typedef VectorMap VirtualBusMap; + + VirtualBusMap fVirtualBusMap; int fNextVirtualBus; }; From marcusoverhagen at mail.berlios.de Sun Feb 17 15:59:53 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 17 Feb 2008 15:59:53 +0100 Subject: [Haiku-commits] r23982 - haiku/trunk/src/system/kernel/fs Message-ID: <200802171459.m1HExrCw023603@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-17 15:59:52 +0100 (Sun, 17 Feb 2008) New Revision: 23982 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23982&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: build fix for r23929 Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-17 14:44:33 UTC (rev 23981) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-17 14:59:52 UTC (rev 23982) @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include From revol at free.fr Sun Feb 17 16:08:44 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 17 Feb 2008 16:08:44 +0100 CET Subject: [Haiku-commits] r23977 - haiku/trunk/src/apps/mail In-Reply-To: <200802171436.m1HEa2fx022126@sheep.berlios.de> Message-ID: <1620958079-BeMail@laptop> > Author: kirilla > Date: 2008-02-17 15:36:01 +0100 (Sun, 17 Feb 2008) > New Revision: 23977 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23977&view=rev > > Modified: > haiku/trunk/src/apps/mail/MailWindow.cpp > Log: > 0L constant typo? Remove menu item before deleting it. No it's not a typo, it's a gccish which means Long, just like LL means long long, to avoid having to do a cast. A standard way of doing that would be using INT32_C(0), see http://linux.die.net/man/3/int32_c (not sure we have all of them, BeOS didn't have any) Fran?ois. From bonefish at mail.berlios.de Sun Feb 17 16:48:33 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 16:48:33 +0100 Subject: [Haiku-commits] r23983 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/kernel/fs Message-ID: <200802171548.m1HFmXod027887@sheep.berlios.de> Author: bonefish Date: 2008-02-17 16:48:30 +0100 (Sun, 17 Feb 2008) New Revision: 23983 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23983&view=rev Added: haiku/trunk/headers/private/kernel/syscall_restart.h haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Removed: haiku/trunk/src/system/kernel/arch/x86/arch_thread.c Modified: haiku/trunk/headers/private/kernel/arch/thread.h haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/arch/x86/Jamfile haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S haiku/trunk/src/system/kernel/fs/fd.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/kernel/port.cpp haiku/trunk/src/system/kernel/sem.cpp haiku/trunk/src/system/kernel/signal.cpp haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/kernel/wait_for_objects.cpp Log: axeld + bonefish: * Implemented automatic syscall restarts: - A syscall can indicate that it has been interrupted and can be restarted by setting a respective bit in thread::flags. It can store parameters it wants to be preserved for the restart in thread::syscall_restart::parameters. Another thread::flags bit indicates whether it has been restarted. - handle_signals() clears the restart flag, if the handled signal has a handler function installed and SA_RESTART is not set. Another thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls from being restarted, even if they could be (not used yet, but we might want to use it in resume_thread(), so that we stay behaviorally compatible with BeOS). - The architecture specific syscall handler restarts the syscall, if the restart flag is set. Implemented for x86 only. - Added some support functions in the private to simplify the syscall restart code in the syscalls. - Adjusted all syscalls that can potentially be restarted accordingly. - _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while calling the underlying FS's/driver's hook, so that syscall restarts can also be supported there. * thread_at_kernel_exit() invokes handle_signals() in a loop now, as long as the latter indicates that the thread shall be suspended, so that after waking up signals received in the meantime will be handled before the thread returns to userland. Adjusted handle_signals() accordingly -- when encountering a suspending signal we don't check for further signals. * Fixed sigsuspend(): Suspending the thread and rescheduling doesn't result in the correct behavior. Instead we employ a temporary condition variable and interruptably wait on it. The POSIX test suite test passes, now. * Made the switch_sem[_etc]() behavior on interruption consistent. Depending on when the signal arrived (before the call or when already waiting) the first semaphore would or wouldn't be released. Now we consistently release it. * Refactored _user_{read,write}[v]() syscalls. Use a common function for either pair. The iovec version doesn't fail anymore, if anything could be read/written at all. It also checks whether a complete vector could be read/written, so that we won't skip data, if the underlying FS/driver couldn't read/write more ATM. * Some refactoring in the x86 syscall handler: The int 99 and sysenter handlers use a common subroutine to avoid code duplication. Modified: haiku/trunk/headers/private/kernel/arch/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/thread.h 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/headers/private/kernel/arch/thread.h 2008-02-17 15:48:30 UTC (rev 23983) @@ -41,7 +41,6 @@ status_t arch_setup_signal_frame(struct thread *t, struct sigaction *sa, int signal, int signalMask); int64 arch_restore_signal_frame(void); -void arch_check_syscall_restart(struct thread *t); void arch_store_fork_frame(struct arch_fork_arg *arg); void arch_restore_fork_frame(struct arch_fork_arg *arg); Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h 2008-02-17 15:48:30 UTC (rev 23983) @@ -19,6 +19,8 @@ struct iframe *i386_get_user_iframe(void); void *x86_next_page_directory(struct thread *from, struct thread *to); +void x86_restart_syscall(struct iframe* frame); + void i386_return_from_signal(); void i386_end_return_from_signal(); Added: haiku/trunk/headers/private/kernel/syscall_restart.h =================================================================== --- haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-17 15:48:30 UTC (rev 23983) @@ -0,0 +1,100 @@ +/* + * Copyright 2008, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_SYSCALL_RESTART_H +#define _KERNEL_SYSCALL_RESTART_H + +#include + +#include + + +static inline void +syscall_restart_handle_timeout_pre(bigtime_t& timeout) +{ + // If restarted, get the timeout from the restart parameters. Otherwise + // convert relative timeout to an absolute one. + struct thread* thread = thread_get_current_thread(); + if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) + timeout = *(bigtime_t*)thread->syscall_restart.parameters; + else if (timeout >= 0) { + timeout += system_time(); + if (timeout < 0) + timeout = B_INFINITE_TIMEOUT; + } +} + + +static inline void +syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) +{ + // If restarted, get the timeout from the restart parameters. Otherwise + // convert relative timeout to an absolute one. + struct thread* thread = thread_get_current_thread(); + if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) + timeout = *(bigtime_t*)thread->syscall_restart.parameters; + else if ((flags & B_RELATIVE_TIMEOUT) != 0) { + timeout += system_time(); + if (timeout < 0) + timeout = B_INFINITE_TIMEOUT; + } + + // any timeout is absolute at this point + if ((flags & B_RELATIVE_TIMEOUT) != 0) + flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; +} + + +static inline status_t +syscall_restart_handle_timeout_post(status_t error, bigtime_t timeout) +{ + if (error == B_INTERRUPTED) { + // interrupted -- store timeout and set flag for syscall restart + struct thread* thread = thread_get_current_thread(); + *(bigtime_t*)thread->syscall_restart.parameters = timeout; + atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL); + } + + return error; +} + + +static inline status_t +syscall_restart_handle_post(status_t error) +{ + if (error == B_INTERRUPTED) { + // interrupted -- set flag for syscall restart + struct thread* thread = thread_get_current_thread(); + atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL); + } + + return error; +} + + +static inline bool +syscall_restart_ioctl_is_restarted() +{ + struct thread* thread = thread_get_current_thread(); + + return (thread->flags & THREAD_FLAGS_IOCTL_SYSCALL) != 0 + && (thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0; +} + + +static inline status_t +syscall_restart_ioctl_handle_post(status_t error) +{ + if (error == B_INTERRUPTED) { + // interrupted -- set flag for syscall restart + struct thread* thread = thread_get_current_thread(); + if ((thread->flags & THREAD_FLAGS_IOCTL_SYSCALL) != 0) + atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL); + } + + return error; +} + + +#endif // _KERNEL_SYSCALL_RESTART_H Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-02-17 15:48:30 UTC (rev 23983) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Haiku Inc. + * Copyright 2004-2008, Haiku Inc. * Distributed under the terms of the MIT License. * * Thread definition and structures @@ -205,6 +205,10 @@ size_t signal_stack_size; bool signal_stack_enabled; + struct { + uint8 parameters[32]; + } syscall_restart; + bool in_kernel; bool was_yielded; @@ -278,12 +282,16 @@ // bits for the thread::flags field -#define THREAD_FLAGS_SIGNALS_PENDING 0x01 -#define THREAD_FLAGS_DEBUG_THREAD 0x02 -#define THREAD_FLAGS_DEBUGGER_INSTALLED 0x04 -#define THREAD_FLAGS_BREAKPOINTS_DEFINED 0x08 -#define THREAD_FLAGS_BREAKPOINTS_INSTALLED 0x10 -#define THREAD_FLAGS_64_BIT_SYSCALL_RETURN 0x20 +#define THREAD_FLAGS_SIGNALS_PENDING 0x0001 +#define THREAD_FLAGS_DEBUG_THREAD 0x0002 +#define THREAD_FLAGS_DEBUGGER_INSTALLED 0x0004 +#define THREAD_FLAGS_BREAKPOINTS_DEFINED 0x0008 +#define THREAD_FLAGS_BREAKPOINTS_INSTALLED 0x0010 +#define THREAD_FLAGS_64_BIT_SYSCALL_RETURN 0x0020 +#define THREAD_FLAGS_RESTART_SYSCALL 0x0040 +#define THREAD_FLAGS_DONT_RESTART_SYSCALL 0x0080 +#define THREAD_FLAGS_SYSCALL_RESTARTED 0x0100 +#define THREAD_FLAGS_IOCTL_SYSCALL 0x0200 #endif /* _KERNEL_THREAD_TYPES_H */ Modified: haiku/trunk/src/system/kernel/arch/x86/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/src/system/kernel/arch/x86/Jamfile 2008-02-17 15:48:30 UTC (rev 23983) @@ -22,7 +22,7 @@ arch_real_time_clock.c arch_smp.c arch_string.S - arch_thread.c + arch_thread.cpp arch_timer.c arch_vm.cpp arch_vm_translation_map.cpp Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-02-17 15:48:30 UTC (rev 23983) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, The Haiku Team. All rights reserved. + * Copyright 2002-2008, The Haiku Team. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001, Travis Geiselbrecht. All rights reserved. @@ -304,6 +304,12 @@ // push error, vector, orig_edx, orig_eax, and other registers PUSH_IFRAME_BOTTOM_SYSCALL() + call handle_syscall + + POP_IFRAME_AND_RETURN() + + +handle_syscall: // save %eax, the number of the syscall movl %eax, %esi @@ -312,7 +318,7 @@ movl %eax,%ds movl %eax,%es - movl %esp, %ebp // frame pointer is the iframe + lea 4(%esp), %ebp // stack frame pointer is the iframe movl %dr3, %edi // thread pointer // disable breakpoints, if installed @@ -351,16 +357,20 @@ testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ - | THREAD_FLAGS_64_BIT_SYSCALL_RETURN) \ + | THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ + | THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_SYSCALL_RESTARTED) \ , THREAD_flags(%edi) jnz post_syscall_work cli // disable interrupts - // update the thread's kernel time and return + // update the thread's kernel time UPDATE_THREAD_KERNEL_TIME() - POP_IFRAME_AND_RETURN() + lea -4(%ebp), %esp // remove all parameters from the stack + + ret + do_pre_syscall_debug: movl %esp, %eax // syscall parameters push %eax @@ -370,15 +380,16 @@ addl $8, %esp jmp pre_syscall_debug_done - post_syscall_work_sysenter: post_syscall_work: - // if the 64 bit return value bit is set, we have to clear it - testl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, THREAD_flags(%edi) + // clear the 64 bit return value and syscall restarted bits + testl $(THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ + | THREAD_FLAGS_SYSCALL_RESTARTED), THREAD_flags(%edi) jz 2f 1: movl THREAD_flags(%edi), %eax movl %eax, %edx - andl $~THREAD_FLAGS_64_BIT_SYSCALL_RETURN, %edx + andl $~(THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ + | THREAD_FLAGS_SYSCALL_RESTARTED), %edx lock cmpxchgl %edx, THREAD_flags(%edi) jnz 1b @@ -410,6 +421,15 @@ call thread_at_kernel_exit_no_signals kernel_exit_work_done: + // syscall restart + // TODO: this only needs to be done for syscalls! + testl $THREAD_FLAGS_RESTART_SYSCALL, THREAD_flags(%edi) + jz 1f + push %ebp + call x86_restart_syscall + addl $4, %esp + 1: + // install breakpoints, if defined testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) jz 1f @@ -417,7 +437,7 @@ call x86_init_user_debug_at_kernel_exit 1: POP_IFRAME_AND_RETURN() - + kernel_exit_handle_signals: // make sure interrupts are enabled (they are, when coming from a syscall // but otherwise they might be disabled) @@ -455,63 +475,8 @@ PUSH_IFRAME_BOTTOM_SYSCALL() - // save %eax, the number of the syscall - movl %eax, %esi + call handle_syscall - movl $KERNEL_DATA_SEG,%eax - cld - movl %eax,%ds - movl %eax,%es - - movl %esp, %ebp // frame pointer is the iframe - movl %dr3, %edi // thread pointer - - // disable breakpoints, if installed - cli // disable interrupts - DISABLE_BREAKPOINTS() - - // update the thread's user time - UPDATE_THREAD_USER_TIME_PUSH_TIME() - // leave the time on the stack (needed for post syscall debugging) - - sti // enable interrupts - - cmp $SYSCALL_COUNT, %esi // check syscall number - jae bad_syscall_number - movl $kSyscallInfos, %eax // get syscall info - lea (%eax, %esi, SYSCALL_INFO_sizeof), %edx - - // copy parameters onto this stack - COPY_SYSCALL_PARAMETERS() - - // pre syscall debugging - TRACE_PRE_SYSCALL() - testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) - jnz do_pre_syscall_debug - // if debugging is enabled, we take the slow syscall exit - - // call the syscall function - call *SYSCALL_INFO_function(%esi) - - // overwrite the values of %eax and %edx on the stack (the syscall return - // value) - movl %edx, IFRAME_edx(%ebp) - movl %eax, IFRAME_eax(%ebp) - - TRACE_POST_SYSCALL() - - testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ - | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ - | THREAD_FLAGS_64_BIT_SYSCALL_RETURN) \ - , THREAD_flags(%edi) - jnz post_syscall_work_sysenter - // if any special work has to be done, we take the slow syscall exit - - cli // disable interrupts - - // update the thread's kernel time - UPDATE_THREAD_KERNEL_TIME() - // pop the bottom of the iframe lea 4(%ebp), %esp // skip iframe type Deleted: haiku/trunk/src/system/kernel/arch/x86/arch_thread.c Copied: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp (from rev 23931, haiku/trunk/src/system/kernel/arch/x86/arch_thread.c) =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.c 2008-02-08 12:16:49 UTC (rev 23931) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-17 15:48:30 UTC (rev 23983) @@ -0,0 +1,617 @@ +/* + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +//#define TRACE_ARCH_THREAD +#ifdef TRACE_ARCH_THREAD +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +#ifdef SYSCALL_TRACING + +namespace SyscallTracing { + +class RestartSyscall : public AbstractTraceEntry { + public: + RestartSyscall() + { + Initialized(); + } + + virtual void AddDump(TraceOutput& out) + { + out.Print("syscall restart"); + } +}; + +} + +# define TSYSCALL(x) new(std::nothrow) SyscallTracing::x + +#else +# define TSYSCALL(x) +#endif // SYSCALL_TRACING + + +// from arch_interrupts.S +extern "C" void i386_stack_init(struct farcall *interrupt_stack_offset); +extern "C" void i386_restore_frame_from_syscall(struct iframe frame); + +// from arch_cpu.c +extern void (*gX86SwapFPUFunc)(void *oldState, const void *newState); +extern bool gHasSSE; + +static struct arch_thread sInitialState _ALIGNED(16); + // the fpu_state must be aligned on a 16 byte boundary, so that fxsave can use it + + +status_t +arch_thread_init(struct kernel_args *args) +{ + // save one global valid FPU state; it will be copied in the arch dependent + // part of each new thread + + asm volatile ("clts; fninit; fnclex;"); + if (gHasSSE) + i386_fxsave(sInitialState.fpu_state); + else + i386_fnsave(sInitialState.fpu_state); + + return B_OK; +} + + +static struct iframe * +find_previous_iframe(addr_t frame) +{ + struct thread *thread = thread_get_current_thread(); + + // iterate backwards through the stack frames, until we hit an iframe + while (frame >= thread->kernel_stack_base + && frame < thread->kernel_stack_base + KERNEL_STACK_SIZE) { + addr_t previousFrame = *(addr_t*)frame; + if ((previousFrame & ~IFRAME_TYPE_MASK) == 0) { + if (previousFrame == 0) + return NULL; + return (struct iframe*)frame; + } + + frame = previousFrame; + } + + return NULL; +} + + +static struct iframe* +get_previous_iframe(struct iframe* frame) +{ + if (frame == NULL) + return NULL; + + return find_previous_iframe(frame->ebp); +} + + +/*! + Returns the current iframe structure of the running thread. + This function must only be called in a context where it's actually + sure that such iframe exists; ie. from syscalls, but usually not + from standard kernel threads. +*/ +static struct iframe* +get_current_iframe(void) +{ + return find_previous_iframe(x86_read_ebp()); +} + + +/*! + \brief Returns the current thread's topmost (i.e. most recent) + userland->kernel transition iframe (usually the first one, save for + interrupts in signal handlers). + \return The iframe, or \c NULL, if there is no such iframe (e.g. when + the thread is a kernel thread). +*/ +struct iframe * +i386_get_user_iframe(void) +{ + struct iframe* frame = get_current_iframe(); + + while (frame != NULL) { + if (frame->cs == USER_CODE_SEG) + return frame; + frame = get_previous_iframe(frame); + } + + return NULL; +} + + +void * +x86_next_page_directory(struct thread *from, struct thread *to) +{ + if (from->team->address_space != NULL && to->team->address_space != NULL) { + // they are both user space threads + if (from->team == to->team) { + // dont change the pgdir, same address space + return NULL; + } + // switching to a new address space + return i386_translation_map_get_pgdir(&to->team->address_space->translation_map); + } else if (from->team->address_space == NULL && to->team->address_space == NULL) { + // they must both be kernel space threads + return NULL; + } else if (to->team->address_space == NULL) { + // the one we're switching to is kernel space + return i386_translation_map_get_pgdir(&vm_kernel_address_space()->translation_map); + } + + return i386_translation_map_get_pgdir(&to->team->address_space->translation_map); +} + + +static inline void +set_fs_register(uint32 segment) +{ + asm("movl %0,%%fs" :: "r" (segment)); +} + + +static void +set_tls_context(struct thread *thread) +{ + int entry = smp_get_current_cpu() + TLS_BASE_SEGMENT; + + set_segment_descriptor_base(&gGDT[entry], thread->user_local_storage); + set_fs_register((entry << 3) | DPL_USER); +} + + +void +x86_restart_syscall(struct iframe* frame) +{ + struct thread* thread = thread_get_current_thread(); + + atomic_and(&thread->flags, ~THREAD_FLAGS_RESTART_SYSCALL); + atomic_or(&thread->flags, THREAD_FLAGS_SYSCALL_RESTARTED); + + frame->eax = frame->orig_eax; + frame->edx = frame->orig_edx; + frame->eip -= 2; + // undoes the "int $99"/"sysenter"/"syscall" instruction + // (so that it'll be executed again) + + TSYSCALL(RestartSyscall()); +} + + +static uint32 * +get_signal_stack(struct thread *thread, struct iframe *frame, int signal) +{ + // use the alternate signal stack if we should and can + if (thread->signal_stack_enabled + && (thread->sig_action[signal - 1].sa_flags & SA_ONSTACK) != 0 + && (frame->user_esp < thread->signal_stack_base + || frame->user_esp >= thread->signal_stack_base + + thread->signal_stack_size)) { + return (uint32 *)(thread->signal_stack_base + + thread->signal_stack_size); + } + + return (uint32 *)frame->user_esp; +} + + +// #pragma mark - + + +status_t +arch_team_init_team_struct(struct team *p, bool kernel) +{ + return B_OK; +} + + +status_t +arch_thread_init_thread_struct(struct thread *thread) +{ + // set up an initial state (stack & fpu) + memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); + return B_OK; +} + + +status_t +arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), + void (*entry_func)(void), void (*exit_func)(void)) +{ + addr_t *kstack = (addr_t *)t->kernel_stack_base; + addr_t *kstack_top = kstack + KERNEL_STACK_SIZE / sizeof(addr_t); + int i; + + TRACE(("arch_thread_initialize_kthread_stack: kstack 0x%p, start_func 0x%p, entry_func 0x%p\n", + kstack, start_func, entry_func)); + + // clear the kernel stack +#ifdef DEBUG_KERNEL_STACKS +# ifdef STACK_GROWS_DOWNWARDS + memset((void *)((addr_t)kstack + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE), 0, + KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); +# else + memset(kstack, 0, KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); +# endif +#else + memset(kstack, 0, KERNEL_STACK_SIZE); +#endif + + // set the final return address to be thread_kthread_exit + kstack_top--; + *kstack_top = (unsigned int)exit_func; + + // set the return address to be the start of the first function + kstack_top--; + *kstack_top = (unsigned int)start_func; + + // set the return address to be the start of the entry (thread setup) + // function + kstack_top--; + *kstack_top = (unsigned int)entry_func; + + // simulate pushfl +// kstack_top--; +// *kstack_top = 0x00; // interrupts still disabled after the switch + + // simulate initial popad + for (i = 0; i < 8; i++) { + kstack_top--; + *kstack_top = 0; + } + + // save the stack position + t->arch_info.current_stack.esp = kstack_top; + t->arch_info.current_stack.ss = (addr_t *)KERNEL_DATA_SEG; + + return B_OK; +} + + +/** Initializes the user-space TLS local storage pointer in + * the thread structure, and the reserved TLS slots. + * + * Is called from _create_user_thread_kentry(). + */ + +status_t +arch_thread_init_tls(struct thread *thread) +{ + uint32 tls[TLS_THREAD_ID_SLOT + 1]; + int32 i; + + thread->user_local_storage = thread->user_stack_base + + thread->user_stack_size; + + // initialize default TLS fields + tls[TLS_BASE_ADDRESS_SLOT] = thread->user_local_storage; + tls[TLS_THREAD_ID_SLOT] = thread->id; + + return user_memcpy((void *)thread->user_local_storage, tls, sizeof(tls)); +} + + +void +arch_thread_switch_kstack_and_call(struct thread *t, addr_t new_kstack, + void (*func)(void *), void *arg) +{ + i386_switch_stack_and_call(new_kstack, func, arg); +} + + +void +arch_thread_context_switch(struct thread *from, struct thread *to) +{ + addr_t newPageDirectory; + +#if 0 + int i; + + dprintf("arch_thread_context_switch: cpu %d 0x%x -> 0x%x, aspace 0x%x -> 0x%x, old stack = 0x%x:0x%x, stack = 0x%x:0x%x\n", + smp_get_current_cpu(), t_from->id, t_to->id, + t_from->team->address_space, t_to->team->address_space, + t_from->arch_info.current_stack.ss, t_from->arch_info.current_stack.esp, + t_to->arch_info.current_stack.ss, t_to->arch_info.current_stack.esp); +#endif +#if 0 + for (i = 0; i < 11; i++) + dprintf("*esp[%d] (0x%x) = 0x%x\n", i, ((unsigned int *)new_at->esp + i), *((unsigned int *)new_at->esp + i)); +#endif + i386_set_tss_and_kstack(to->kernel_stack_base + KERNEL_STACK_SIZE); + + // set TLS GDT entry to the current thread - since this action is + // dependent on the current CPU, we have to do it here + if (to->user_local_storage != NULL) + set_tls_context(to); + + newPageDirectory = (addr_t)x86_next_page_directory(from, to); + + if ((newPageDirectory % B_PAGE_SIZE) != 0) + panic("arch_thread_context_switch: bad pgdir 0x%lx\n", newPageDirectory); + + gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state); + i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory); +} + + +void +arch_thread_dump_info(void *info) +{ + struct arch_thread *at = (struct arch_thread *)info; + + kprintf("\tesp: %p\n", at->current_stack.esp); + kprintf("\tss: %p\n", at->current_stack.ss); + kprintf("\tfpu_state at %p\n", at->fpu_state); +} + + +/** Sets up initial thread context and enters user space + */ + +status_t +arch_thread_enter_userspace(struct thread *t, addr_t entry, void *args1, + void *args2) +{ + addr_t stackTop = t->user_stack_base + t->user_stack_size; + uint32 codeSize = (addr_t)x86_end_userspace_thread_exit + - (addr_t)x86_userspace_thread_exit; + uint32 args[3]; + + TRACE(("arch_thread_enter_uspace: entry 0x%lx, args %p %p, ustack_top 0x%lx\n", + entry, args1, args2, stackTop)); + + // copy the little stub that calls exit_thread() when the thread entry + // function returns, as well as the arguments of the entry function + stackTop -= codeSize; + + if (user_memcpy((void *)stackTop, x86_userspace_thread_exit, codeSize) < B_OK) + return B_BAD_ADDRESS; + + args[0] = stackTop; + args[1] = (uint32)args1; + args[2] = (uint32)args2; + stackTop -= sizeof(args); + + if (user_memcpy((void *)stackTop, args, sizeof(args)) < B_OK) + return B_BAD_ADDRESS; + + disable_interrupts(); + + i386_set_tss_and_kstack(t->kernel_stack_base + KERNEL_STACK_SIZE); + + // set the CPU dependent GDT entry for TLS + set_tls_context(t); + + x86_enter_userspace(entry, stackTop); + + return B_OK; + // never gets here +} + + +bool +arch_on_signal_stack(struct thread *thread) +{ + struct iframe *frame = get_current_iframe(); + + return frame->user_esp >= thread->signal_stack_base + && frame->user_esp < thread->signal_stack_base + + thread->signal_stack_size; +} + + +status_t +arch_setup_signal_frame(struct thread *thread, struct sigaction *action, + int signal, int signalMask) +{ + struct iframe *frame = get_current_iframe(); + uint32 *signalCode; + uint32 *userRegs; + struct vregs regs; + uint32 buffer[6]; + status_t status; + + // start stuffing stuff on the user stack + uint32* userStack = get_signal_stack(thread, frame, signal); + + // copy syscall restart info onto the user stack + userStack -= (sizeof(thread->syscall_restart.parameters) + 12 + 3) / 4; + uint32 threadFlags = atomic_and(&thread->flags, + ~(THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_64_BIT_SYSCALL_RETURN)); + if (user_memcpy(userStack, &threadFlags, 4) < B_OK + || user_memcpy(userStack + 1, &frame->orig_eax, 4) < B_OK + || user_memcpy(userStack + 2, &frame->orig_edx, 4) < B_OK) + return B_BAD_ADDRESS; + status = user_memcpy(userStack + 3, thread->syscall_restart.parameters, + sizeof(thread->syscall_restart.parameters)); + if (status < B_OK) + return status; + + // store the saved regs onto the user stack + regs.eip = frame->eip; + regs.eflags = frame->flags; + regs.eax = frame->eax; + regs.ecx = frame->ecx; + regs.edx = frame->edx; + regs.esp = frame->esp; + regs._reserved_1 = frame->user_esp; + regs._reserved_2[0] = frame->edi; + regs._reserved_2[1] = frame->esi; + regs._reserved_2[2] = frame->ebp; + i386_fnsave((void *)(®s.xregs)); + + userStack -= (sizeof(struct vregs) + 3) / 4; + userRegs = userStack; + status = user_memcpy(userRegs, ®s, sizeof(regs)); + if (status < B_OK) + return status; + + // now store a code snippet on the stack + userStack -= ((uint32)i386_end_return_from_signal + 3 + - (uint32)i386_return_from_signal) / 4; + signalCode = userStack; + status = user_memcpy(signalCode, i386_return_from_signal, + ((uint32)i386_end_return_from_signal + - (uint32)i386_return_from_signal)); + if (status < B_OK) + return status; + + // now set up the final part + buffer[0] = (uint32)signalCode; // return address when sa_handler done + buffer[1] = signal; // arguments to sa_handler + buffer[2] = (uint32)action->sa_userdata; + buffer[3] = (uint32)userRegs; + + buffer[4] = signalMask; // Old signal mask to restore + buffer[5] = (uint32)userRegs; // Int frame + extra regs to restore + + userStack -= sizeof(buffer) / 4; + + status = user_memcpy(userStack, buffer, sizeof(buffer)); + if (status < B_OK) + return status; + + frame->user_esp = (uint32)userStack; + frame->eip = (uint32)action->sa_handler; + + return B_OK; +} + + +int64 +arch_restore_signal_frame(void) +{ + struct thread *thread = thread_get_current_thread(); + struct iframe *frame = get_current_iframe(); + int32 signalMask; + uint32 *userStack; + struct vregs* regsPointer; + struct vregs regs; + + TRACE(("### arch_restore_signal_frame: entry\n")); + + userStack = (uint32 *)frame->user_esp; + if (user_memcpy(&signalMask, &userStack[0], 4) < B_OK + || user_memcpy(®sPointer, &userStack[1], 4) < B_OK + || user_memcpy(®s, regsPointer, sizeof(vregs)) < B_OK) { + return B_BAD_ADDRESS; + } + + uint32* syscallRestartInfo + = (uint32*)regsPointer + (sizeof(struct vregs) + 3) / 4; + uint32 threadFlags; + if (user_memcpy(&threadFlags, syscallRestartInfo, 4) < B_OK + || user_memcpy(&frame->orig_eax, syscallRestartInfo + 1, 4) < B_OK + || user_memcpy(&frame->orig_edx, syscallRestartInfo + 2, 4) < B_OK + || user_memcpy(thread->syscall_restart.parameters, + syscallRestartInfo + 3, + sizeof(thread->syscall_restart.parameters)) < B_OK) { + return B_BAD_ADDRESS; + } + + // set restart/64bit return value flags from previous syscall + atomic_and(&thread->flags, + ~(THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_64_BIT_SYSCALL_RETURN)); + atomic_or(&thread->flags, threadFlags + & (THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_64_BIT_SYSCALL_RETURN)); + + atomic_set(&thread->sig_block_mask, signalMask); + + frame->eip = regs.eip; + frame->flags = regs.eflags; + frame->eax = regs.eax; + frame->ecx = regs.ecx; + frame->edx = regs.edx; + frame->esp = regs.esp; + frame->user_esp = regs._reserved_1; + frame->edi = regs._reserved_2[0]; + frame->esi = regs._reserved_2[1]; + frame->ebp = regs._reserved_2[2]; + + i386_frstor((void *)(®s.xregs)); + + TRACE(("### arch_restore_signal_frame: exit\n")); + + return (int64)frame->eax | ((int64)frame->edx << 32); +} + + +/** Saves everything needed to restore the frame in the child fork in the + * arch_fork_arg structure to be passed to arch_restore_fork_frame(). + * Also makes sure to return the right value. + */ + +void +arch_store_fork_frame(struct arch_fork_arg *arg) +{ + struct iframe *frame = get_current_iframe(); + + // we need to copy the threads current iframe + arg->iframe = *frame; + + // we also want fork() to return 0 for the child + arg->iframe.eax = 0; +} + + +/** Restores the frame from a forked team as specified by the provided + * arch_fork_arg structure. + * Needs to be called from within the child team, ie. instead of + * arch_thread_enter_uspace() as thread "starter". + * This function does not return to the caller, but will enter userland + * in the child team at the same position where the parent team left of. + */ + +void +arch_restore_fork_frame(struct arch_fork_arg *arg) +{ + struct thread *thread = thread_get_current_thread(); + + disable_interrupts(); + + i386_set_tss_and_kstack(thread->kernel_stack_base + KERNEL_STACK_SIZE); + + // set the CPU dependent GDT entry for TLS (set the current %fs register) + set_tls_context(thread); + + i386_restore_frame_from_syscall(arg->iframe); +} + + +void +arch_syscall_64_bit_return_value(void) +{ + struct thread* thread = thread_get_current_thread(); + atomic_or(&thread->flags, THREAD_FLAGS_64_BIT_SYSCALL_RETURN); +} Modified: haiku/trunk/src/system/kernel/fs/fd.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fd.cpp 2008-02-17 14:59:52 UTC (rev 23982) +++ haiku/trunk/src/system/kernel/fs/fd.cpp 2008-02-17 15:48:30 UTC (rev 23983) @@ -12,7 +12,10 @@ #include +#include + #include +#include #include [... truncated: 1125 lines follow ...] From bonefish at mail.berlios.de Sun Feb 17 17:25:08 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 17:25:08 +0100 Subject: [Haiku-commits] r23984 - in haiku/trunk: headers/private/net src/add-ons/kernel/drivers/network/stack src/add-ons/kernel/network/protocols/tcp src/add-ons/kernel/network/stack Message-ID: <200802171625.m1HGP8To030242@sheep.berlios.de> Author: bonefish Date: 2008-02-17 17:25:07 +0100 (Sun, 17 Feb 2008) New Revision: 23984 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23984&view=rev Modified: haiku/trunk/headers/private/net/ProtocolUtilities.h haiku/trunk/headers/private/net/net_stack.h haiku/trunk/src/add-ons/kernel/drivers/network/stack/kernel_stack.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp haiku/trunk/src/add-ons/kernel/network/stack/utility.h Log: axeld + bonefish: * Added syscall restart support for connect(), accept(), send(), recv(), which are implemented via ioctl()s. The actual restart support is done in the net stack driver's ioctl() hook. Lower layers need to correctly deal with socket timeouts, though, for which the stack module provides support functions. * TCPEndpoint::_WaitForEstablished() does abort now when an error occurred earlier, so that trying to connect to an unused port fails immediately, as it should. * Fixed and refactored TCP connection reset handling. The new TCPEndpoint::_HandleReset() does the job. Got rid of TCPEndpoint::fError. * Fixed sequence numbers for SYNC/FINI packets. * The former two fix the problem that connections wouldn't be closed correctly and could even be reused when trying to connect again (as was reproducible with svnserve + svn). * Some style cleanup in CPEndpoint.h. Modified: haiku/trunk/headers/private/net/ProtocolUtilities.h =================================================================== --- haiku/trunk/headers/private/net/ProtocolUtilities.h 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/headers/private/net/ProtocolUtilities.h 2008-02-17 16:25:07 UTC (rev 23984) @@ -348,6 +348,11 @@ else if (timeout != 0 && timeout != B_INFINITE_TIMEOUT) timeout += system_time(); + if (ModuleBundle::Stack()->is_restarted_syscall()) + timeout = ModuleBundle::Stack()->restore_syscall_restart_timeout(); + else + ModuleBundle::Stack()->store_syscall_restart_timeout(timeout); + return timeout; } Modified: haiku/trunk/headers/private/net/net_stack.h =================================================================== --- haiku/trunk/headers/private/net/net_stack.h 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/headers/private/net/net_stack.h 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef NET_STACK_H @@ -44,9 +44,10 @@ bigtime_t due; }; -typedef int32 (*net_deframe_func)(struct net_device *device, struct net_buffer *buffer); -typedef status_t (*net_receive_func)(void *cookie, struct net_device *, +typedef int32 (*net_deframe_func)(struct net_device *device, struct net_buffer *buffer); +typedef status_t (*net_receive_func)(void *cookie, struct net_device *device, + struct net_buffer *buffer); enum { B_DEVICE_GOING_UP = 1, @@ -132,6 +133,11 @@ void (*set_timer)(struct net_timer *timer, bigtime_t delay); bool (*cancel_timer)(struct net_timer *timer); bool (*is_timer_active)(struct net_timer *timer); + + // syscall restart + bool (*is_restarted_syscall)(void); + void (*store_syscall_restart_timeout)(bigtime_t timeout); + bigtime_t (*restore_syscall_restart_timeout)(void); }; #endif // NET_STACK_H Modified: haiku/trunk/src/add-ons/kernel/drivers/network/stack/kernel_stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/stack/kernel_stack.cpp 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/drivers/network/stack/kernel_stack.cpp 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2008, Haiku, Inc. All Rights Reserved. * This file may be used under the terms of the MIT License. */ @@ -10,16 +10,17 @@ #include -#include #include #include +#include +#include #include #include -#include -#include // IS_KERNEL_ADDRESS -#include // user_fd_kernel_ioctl +#include +#include +#include #include @@ -96,8 +97,9 @@ static status_t -check_message_args(message_args &args, msghdr &header, sockaddr_storage &address, - void *data, size_t length, sockaddr **originalAddress) +check_message_args(message_args &args, msghdr &header, + sockaddr_storage &address, void *data, size_t length, + sockaddr **originalAddress) { if (length < sizeof(message_args)) return B_BAD_VALUE; @@ -133,6 +135,7 @@ return B_OK; } + template status_t check_args(ArgType &args, void *data, size_t length) { @@ -205,9 +208,9 @@ { if (kernel) return ioctl(socket, NET_STACK_GET_COOKIE, cookie, sizeof(*cookie)); - else - return user_fd_kernel_ioctl(socket, NET_STACK_GET_COOKIE, cookie, - sizeof(*cookie)); + + return user_fd_kernel_ioctl(socket, NET_STACK_GET_COOKIE, cookie, + sizeof(*cookie)); } @@ -251,7 +254,8 @@ } } - net_stack_cookie *cookie = (net_stack_cookie *)malloc(sizeof(net_stack_cookie)); + net_stack_cookie *cookie = (net_stack_cookie *)malloc( + sizeof(net_stack_cookie)); if (cookie == NULL) return B_NO_MEMORY; @@ -363,7 +367,10 @@ if (status < B_OK) return status; - return sSocket->connect(cookie->socket, args.address, args.address_length); + status = sSocket->connect(cookie->socket, args.address, + args.address_length); + + return syscall_restart_ioctl_handle_post(status); } case NET_STACK_BIND: @@ -387,7 +394,8 @@ sockaddr_storage address; accept_args args; - status = check_args_and_address(args, address, data, length, false); + status = check_args_and_address(args, address, data, length, + false); if (status < B_OK) return status; @@ -399,8 +407,9 @@ status = sSocket->accept(cookie->socket, args.address, &args.address_length, &acceptCookie->socket); + if (status < B_OK) - return status; + return syscall_restart_ioctl_handle_post(status); return return_address(args, data); } @@ -415,13 +424,15 @@ msghdr header; status = check_message_args(args, header, address, data, - length, NULL); + length, NULL); if (status < B_OK) return status; - return sSocket->send(cookie->socket, - args.header ? &header : NULL, - args.data, args.length, args.flags); + ssize_t bytesSent = sSocket->send(cookie->socket, + args.header ? &header : NULL, + args.data, args.length, args.flags); + + return syscall_restart_ioctl_handle_post(bytesSent); } case NET_STACK_RECEIVE: @@ -432,25 +443,25 @@ msghdr header; status = check_message_args(args, header, address, data, - length, &originalAddress); + length, &originalAddress); if (status < B_OK) return status; ssize_t bytesRead = sSocket->receive(cookie->socket, - args.header ? &header : NULL, args.data, - args.length, args.flags); + args.header ? &header : NULL, args.data, + args.length, args.flags); if (bytesRead < B_OK) - return bytesRead; + return syscall_restart_ioctl_handle_post(bytesRead); if (args.header != NULL) { if (header.msg_name != NULL) { if (user_memcpy(originalAddress, header.msg_name, - header.msg_namelen) < B_OK) + header.msg_namelen) < B_OK) return B_BAD_ADDRESS; } if (user_memcpy(&args.header->msg_flags, &header.msg_flags, - sizeof(int)) < B_OK) + sizeof(int)) < B_OK) return B_BAD_ADDRESS; } @@ -468,13 +479,14 @@ if (args.length > (int)sizeof(valueBuffer)) return ENOBUFS; - status = sSocket->getsockopt(cookie->socket, args.level, args.option, - valueBuffer, &args.length); + status = sSocket->getsockopt(cookie->socket, args.level, + args.option, valueBuffer, &args.length); if (status < B_OK) return status; if (user_memcpy(args.value, valueBuffer, args.length) < B_OK - || user_memcpy(&((sockopt_args *)data)->length, &args.length, sizeof(int)) < B_OK) + || user_memcpy(&((sockopt_args *)data)->length, + &args.length, sizeof(int)) < B_OK) return B_BAD_ADDRESS; return B_OK; @@ -493,15 +505,16 @@ if (user_memcpy(valueBuffer, args.value, args.length) < B_OK) return B_BAD_ADDRESS; - return sSocket->setsockopt(cookie->socket, args.level, args.option, - valueBuffer, args.length); + return sSocket->setsockopt(cookie->socket, args.level, + args.option, valueBuffer, args.length); } case NET_STACK_GETSOCKNAME: { sockaddr_storage address; sockaddr_args args; - status = check_args_and_address(args, address, data, length, false); + status = check_args_and_address(args, address, data, length, + false); if (status < B_OK) return status; @@ -517,7 +530,8 @@ { sockaddr_storage address; sockaddr_args args; - status = check_args_and_address(args, address, data, length, false); + status = check_args_and_address(args, address, data, length, + false); if (status < B_OK) return status; @@ -532,16 +546,16 @@ case FIONBIO: { int value = (int)data; - return sSocket->setsockopt(cookie->socket, SOL_SOCKET, SO_NONBLOCK, - &value, sizeof(int)); + return sSocket->setsockopt(cookie->socket, SOL_SOCKET, + SO_NONBLOCK, &value, sizeof(int)); } case B_SET_BLOCKING_IO: case B_SET_NONBLOCKING_IO: { int value = op == B_SET_NONBLOCKING_IO; - return sSocket->setsockopt(cookie->socket, SOL_SOCKET, SO_NONBLOCK, - &value, sizeof(int)); + return sSocket->setsockopt(cookie->socket, SOL_SOCKET, + SO_NONBLOCK, &value, sizeof(int)); } default: Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp 2008-02-17 16:25:07 UTC (rev 23984) @@ -405,6 +405,9 @@ if ((segment.flags & TCP_FLAG_ACKNOWLEDGE) == 0) { outSegment.flags |= TCP_FLAG_ACKNOWLEDGE; outSegment.acknowledge = segment.sequence + buffer->size; + // TODO: Confirm: + if ((segment.flags & (TCP_FLAG_SYNCHRONIZE | TCP_FLAG_FINISH)) != 0) + outSegment.acknowledge++; } else outSegment.sequence = segment.acknowledge; Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-02-17 16:25:07 UTC (rev 23984) @@ -170,6 +170,9 @@ } +// #pragma mark - + + WaitList::WaitList(const char *name) { fCondition = 0; @@ -224,6 +227,9 @@ } +// #pragma mark - + + TCPEndpoint::TCPEndpoint(net_socket *socket) : ProtocolSocket(socket), @@ -255,8 +261,7 @@ fCongestionWindow(0), fSlowStartThreshold(0), fState(CLOSED), - fFlags(FLAG_OPTION_WINDOW_SCALE | FLAG_OPTION_TIMESTAMP), - fError(B_OK) + fFlags(FLAG_OPTION_WINDOW_SCALE | FLAG_OPTION_TIMESTAMP) { //gStackModule->init_timer(&fTimer, _TimeWait, this); @@ -394,13 +399,23 @@ MutexLocker locker(fLock); + if (gStackModule->is_restarted_syscall()) { + bigtime_t timeout = gStackModule->restore_syscall_restart_timeout(); + status_t status = _WaitForEstablished(locker, timeout); + TRACE(" Connect(): Connection complete: %s (timeout was %llu)", + strerror(status), timeout); + return posix_error(status); + } + // Can only call connect() from CLOSED or LISTEN states // otherwise endpoint is considered already connected if (fState == LISTEN) { // this socket is about to connect; remove pending connections in the backlog gSocketModule->set_max_backlog(socket, 0); + } else if (fState == ESTABLISHED) { + return EISCONN; } else if (fState != CLOSED) - return EISCONN; + return EINPROGRESS; status_t status = _PrepareSendPath(address); if (status < B_OK) @@ -432,7 +447,10 @@ return EINPROGRESS; } - status = _WaitForEstablished(locker, absolute_timeout(timeout)); + bigtime_t absoluteTimeout = absolute_timeout(timeout); + gStackModule->store_syscall_restart_timeout(absoluteTimeout); + + status = _WaitForEstablished(locker, absoluteTimeout); TRACE(" Connect(): Connection complete: %s (timeout was %llu)", strerror(status), timeout); return posix_error(status); @@ -448,6 +466,10 @@ status_t status; bigtime_t timeout = absolute_timeout(socket->receive.timeout); + if (gStackModule->is_restarted_syscall()) + timeout = gStackModule->restore_syscall_restart_timeout(); + else + gStackModule->store_syscall_restart_timeout(timeout); do { locker.Unlock(); @@ -567,6 +589,10 @@ return ENOBUFS; bigtime_t timeout = absolute_timeout(socket->send.timeout); + if (gStackModule->is_restarted_syscall()) + timeout = gStackModule->restore_syscall_restart_timeout(); + else + gStackModule->store_syscall_restart_timeout(timeout); while (fSendQueue.Free() < buffer->size) { status_t status = fSendList.Wait(lock, timeout); @@ -632,6 +658,10 @@ return ENOTCONN; bigtime_t timeout = absolute_timeout(socket->receive.timeout); + if (gStackModule->is_restarted_syscall()) + timeout = gStackModule->restore_syscall_restart_timeout(); + else + gStackModule->store_syscall_restart_timeout(timeout); if (fState == SYNCHRONIZE_SENT || fState == SYNCHRONIZE_RECEIVED) { if (flags & MSG_DONTWAIT) @@ -913,11 +943,27 @@ } +void +TCPEndpoint::_HandleReset(status_t error) +{ + gStackModule->cancel_timer(&fRetransmitTimer); + + socket->error = error; + fState = CLOSED; + + fSendList.Signal(); + _NotifyReader(); + + gSocketModule->notify(socket, B_SELECT_WRITE, error); + gSocketModule->notify(socket, B_SELECT_ERROR, error); +} + + int32 TCPEndpoint::_SynchronizeSentReceive(tcp_segment_header &segment, net_buffer *buffer) { - TRACE("SynchronizeSentReceive()"); + TRACE("_SynchronizeSentReceive()"); if ((segment.flags & TCP_FLAG_ACKNOWLEDGE) != 0 && (fInitialSendSequence >= segment.acknowledge @@ -925,8 +971,7 @@ return DROP | RESET; if (segment.flags & TCP_FLAG_RESET) { - fError = ECONNREFUSED; - fState = CLOSED; + _HandleReset(ECONNREFUSED); return DROP; } @@ -1040,8 +1085,10 @@ fReceiveWindow)) { TRACE(" Receive(): segment out of window, next: %lu wnd: %lu", (uint32)fReceiveNext, fReceiveWindow); - if (segment.flags & TCP_FLAG_RESET) + if (segment.flags & TCP_FLAG_RESET) { + // TODO: this doesn't look right - review! return DROP; + } return DROP | IMMEDIATE_ACKNOWLEDGE; } } @@ -1079,7 +1126,7 @@ return TCP_FLAG_ACKNOWLEDGE; default: - return B_ERROR; + return 0; } } @@ -1400,16 +1447,16 @@ if (fLastAcknowledgeSent <= segment.sequence && tcp_sequence(segment.sequence) < (fLastAcknowledgeSent + fReceiveWindow)) { + status_t error; if (fState == SYNCHRONIZE_RECEIVED) - fError = ECONNREFUSED; + error = ECONNREFUSED; else if (fState == CLOSING || fState == TIME_WAIT || fState == WAIT_FOR_FINISH_ACKNOWLEDGE) - fError = ENOTCONN; + error = ENOTCONN; else - fError = ECONNRESET; + error = ECONNRESET; - _NotifyReader(); - fState = CLOSED; + _HandleReset(error); } return DROP; @@ -1635,6 +1682,9 @@ TCPEndpoint::_WaitForEstablished(MutexLocker &locker, bigtime_t timeout) { while (fState != ESTABLISHED) { + if (socket->error != B_OK) + return socket->error; + status_t status = fSendList.Wait(locker, timeout); if (status < B_OK) return status; @@ -1752,7 +1802,7 @@ if (segment.options & TCP_HAS_TIMESTAMPS) _UpdateSRTT(tcp_diff_timestamp(segment.timestamp_reply)); else { - // TODO Fallback to RFC 793 type estimation + // TODO: Fallback to RFC 793 type estimation } if (is_writable(fState)) { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -42,141 +42,141 @@ class TCPEndpoint : public net_protocol, public ProtocolSocket { - public: - TCPEndpoint(net_socket *socket); - ~TCPEndpoint(); +public: + TCPEndpoint(net_socket *socket); + ~TCPEndpoint(); - status_t InitCheck() const; + status_t InitCheck() const; - status_t Open(); - status_t Close(); - status_t Free(); - status_t Connect(const struct sockaddr *address); - status_t Accept(struct net_socket **_acceptedSocket); - status_t Bind(const sockaddr *address); - status_t Unbind(struct sockaddr *address); - status_t Listen(int count); - status_t Shutdown(int direction); - status_t SendData(net_buffer *buffer); - ssize_t SendAvailable(); - status_t ReadData(size_t numBytes, uint32 flags, net_buffer **_buffer); - ssize_t ReadAvailable(); + status_t Open(); + status_t Close(); + status_t Free(); + status_t Connect(const struct sockaddr *address); + status_t Accept(struct net_socket **_acceptedSocket); + status_t Bind(const sockaddr *address); + status_t Unbind(struct sockaddr *address); + status_t Listen(int count); + status_t Shutdown(int direction); + status_t SendData(net_buffer *buffer); + ssize_t SendAvailable(); + status_t ReadData(size_t numBytes, uint32 flags, net_buffer **_buffer); + ssize_t ReadAvailable(); - status_t FillStat(struct net_stat *stat); + status_t FillStat(struct net_stat *stat); - status_t SetSendBufferSize(size_t length); - status_t SetReceiveBufferSize(size_t length); + status_t SetSendBufferSize(size_t length); + status_t SetReceiveBufferSize(size_t length); - status_t SetOption(int option, const void *value, int length); + status_t SetOption(int option, const void *value, int length); - tcp_state State() const { return fState; } - bool IsBound() const; + tcp_state State() const { return fState; } + bool IsBound() const; - status_t DelayedAcknowledge(); - status_t SendAcknowledge(bool force); - status_t UpdateTimeWait(); + status_t DelayedAcknowledge(); + status_t SendAcknowledge(bool force); + status_t UpdateTimeWait(); - int32 SegmentReceived(tcp_segment_header& segment, net_buffer *buffer); - int32 Spawn(TCPEndpoint *parent, tcp_segment_header& segment, - net_buffer *buffer); + int32 SegmentReceived(tcp_segment_header& segment, net_buffer *buffer); + int32 Spawn(TCPEndpoint *parent, tcp_segment_header& segment, + net_buffer *buffer); - void DumpInternalState() const; + void DumpInternalState() const; - private: - friend class EndpointManager; +private: + friend class EndpointManager; - void _StartPersistTimer(); - void _EnterTimeWait(); - uint8 _CurrentFlags(); - bool _ShouldSendSegment(tcp_segment_header &segment, uint32 length, - uint32 segmentMaxSize, uint32 flightSize); - status_t _SendQueued(bool force = false); - status_t _SendQueued(bool force, uint32 sendWindow); - int _MaxSegmentSize(const struct sockaddr *) const; - status_t _ShutdownEgress(bool closing); - ssize_t _AvailableData() const; - void _NotifyReader(); - bool _ShouldReceive() const; - int32 _ListenReceive(tcp_segment_header& segment, net_buffer *buffer); - int32 _SynchronizeSentReceive(tcp_segment_header& segment, - net_buffer *buffer); - int32 _SegmentReceived(tcp_segment_header& segment, net_buffer *buffer); - int32 _Receive(tcp_segment_header& segment, net_buffer *buffer); - void _UpdateTimestamps(tcp_segment_header& segment, - size_t segmentLength); - void _MarkEstablished(); - status_t _WaitForEstablished(MutexLocker &lock, bigtime_t timeout); - bool _AddData(tcp_segment_header &segment, net_buffer *buffer); - void _PrepareReceivePath(tcp_segment_header &segment); - status_t _PrepareSendPath(const sockaddr *peer); - void _Acknowledged(tcp_segment_header &segment); - void _Retransmit(); - void _UpdateSRTT(int32 roundTripTime); - void _ResetSlowStart(); - void _DuplicateAcknowledge(tcp_segment_header &segment); + void _StartPersistTimer(); + void _EnterTimeWait(); + uint8 _CurrentFlags(); + bool _ShouldSendSegment(tcp_segment_header &segment, uint32 length, + uint32 segmentMaxSize, uint32 flightSize); + status_t _SendQueued(bool force = false); + status_t _SendQueued(bool force, uint32 sendWindow); + int _MaxSegmentSize(const struct sockaddr *) const; + status_t _ShutdownEgress(bool closing); + ssize_t _AvailableData() const; + void _NotifyReader(); + bool _ShouldReceive() const; + void _HandleReset(status_t error); + int32 _ListenReceive(tcp_segment_header& segment, net_buffer *buffer); + int32 _SynchronizeSentReceive(tcp_segment_header& segment, + net_buffer *buffer); + int32 _SegmentReceived(tcp_segment_header& segment, net_buffer *buffer); + int32 _Receive(tcp_segment_header& segment, net_buffer *buffer); + void _UpdateTimestamps(tcp_segment_header& segment, + size_t segmentLength); + void _MarkEstablished(); + status_t _WaitForEstablished(MutexLocker &lock, bigtime_t timeout); + bool _AddData(tcp_segment_header &segment, net_buffer *buffer); + void _PrepareReceivePath(tcp_segment_header &segment); + status_t _PrepareSendPath(const sockaddr *peer); + void _Acknowledged(tcp_segment_header &segment); + void _Retransmit(); + void _UpdateSRTT(int32 roundTripTime); + void _ResetSlowStart(); + void _DuplicateAcknowledge(tcp_segment_header &segment); - static void _TimeWaitTimer(net_timer *timer, void *data); - static void _RetransmitTimer(net_timer *timer, void *data); - static void _PersistTimer(net_timer *timer, void *data); - static void _DelayedAcknowledgeTimer(net_timer *timer, void *data); + static void _TimeWaitTimer(net_timer *timer, void *data); + static void _RetransmitTimer(net_timer *timer, void *data); + static void _PersistTimer(net_timer *timer, void *data); + static void _DelayedAcknowledgeTimer(net_timer *timer, void *data); - EndpointManager *fManager; + EndpointManager *fManager; - HashTableLink fConnectionHashLink; - HashTableLink fEndpointHashLink; + HashTableLink fConnectionHashLink; + HashTableLink fEndpointHashLink; - friend class ConnectionHashDefinition; - friend class EndpointHashDefinition; + friend class ConnectionHashDefinition; + friend class EndpointHashDefinition; - mutex fLock; - WaitList fReceiveList; - WaitList fSendList; - sem_id fAcceptSemaphore; - uint8 fOptions; + mutex fLock; + WaitList fReceiveList; + WaitList fSendList; + sem_id fAcceptSemaphore; + uint8 fOptions; - uint8 fSendWindowShift; - uint8 fReceiveWindowShift; + uint8 fSendWindowShift; + uint8 fReceiveWindowShift; - tcp_sequence fSendUnacknowledged; - tcp_sequence fSendNext; - tcp_sequence fSendMax; - uint32 fSendWindow; - uint32 fSendMaxWindow; - uint32 fSendMaxSegmentSize; - BufferQueue fSendQueue; - tcp_sequence fLastAcknowledgeSent; - tcp_sequence fInitialSendSequence; - uint32 fDuplicateAcknowledgeCount; + tcp_sequence fSendUnacknowledged; + tcp_sequence fSendNext; + tcp_sequence fSendMax; + uint32 fSendWindow; + uint32 fSendMaxWindow; + uint32 fSendMaxSegmentSize; + BufferQueue fSendQueue; + tcp_sequence fLastAcknowledgeSent; + tcp_sequence fInitialSendSequence; + uint32 fDuplicateAcknowledgeCount; - net_route *fRoute; - // TODO: don't use a net_route, but a net_route_info!!! + net_route *fRoute; + // TODO: don't use a net_route, but a net_route_info!!! - tcp_sequence fReceiveNext; - tcp_sequence fReceiveMaxAdvertised; - uint32 fReceiveWindow; - uint32 fReceiveMaxSegmentSize; - BufferQueue fReceiveQueue; - tcp_sequence fInitialReceiveSequence; + tcp_sequence fReceiveNext; + tcp_sequence fReceiveMaxAdvertised; + uint32 fReceiveWindow; + uint32 fReceiveMaxSegmentSize; + BufferQueue fReceiveQueue; + tcp_sequence fInitialReceiveSequence; - // round trip time and retransmit timeout computation - int32 fRoundTripTime; - int32 fRoundTripDeviation; - bigtime_t fRetransmitTimeout; + // round trip time and retransmit timeout computation + int32 fRoundTripTime; + int32 fRoundTripDeviation; + bigtime_t fRetransmitTimeout; - uint32 fReceivedTimestamp; + uint32 fReceivedTimestamp; - uint32 fCongestionWindow; - uint32 fSlowStartThreshold; + uint32 fCongestionWindow; + uint32 fSlowStartThreshold; - tcp_state fState; - uint32 fFlags; - status_t fError; + tcp_state fState; + uint32 fFlags; - // timer - net_timer fRetransmitTimer; - net_timer fPersistTimer; - net_timer fDelayedAcknowledgeTimer; - net_timer fTimeWaitTimer; + // timer + net_timer fRetransmitTimer; + net_timer fPersistTimer; + net_timer fDelayedAcknowledgeTimer; + net_timer fTimeWaitTimer; }; #endif // TCP_ENDPOINT_H Modified: haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -932,6 +932,10 @@ set_timer, cancel_timer, is_timer_active, + + is_restarted_syscall, + store_syscall_restart_timeout, + restore_syscall_restart_timeout, }; static module_info sNetStarterModule = { Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -11,6 +11,7 @@ #include "utility.h" #include +#include #include #include @@ -570,3 +571,30 @@ wait_for_thread(sTimerThread, &status); } + +// #pragma mark - Syscall restart + + +bool +is_restarted_syscall(void) +{ + return syscall_restart_ioctl_is_restarted(); +} + + +void +store_syscall_restart_timeout(bigtime_t timeout) +{ + struct thread* thread = thread_get_current_thread(); + if ((thread->flags & THREAD_FLAGS_IOCTL_SYSCALL) != 0) + *(bigtime_t*)thread->syscall_restart.parameters = timeout; +} + + +bigtime_t +restore_syscall_restart_timeout(void) +{ + struct thread* thread = thread_get_current_thread(); + return *(bigtime_t*)thread->syscall_restart.parameters; +} + Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/utility.h 2008-02-17 15:48:30 UTC (rev 23983) +++ haiku/trunk/src/add-ons/kernel/network/stack/utility.h 2008-02-17 16:25:07 UTC (rev 23984) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -101,4 +101,9 @@ status_t init_timers(void); void uninit_timers(void); +// syscall restart +bool is_restarted_syscall(void); +void store_syscall_restart_timeout(bigtime_t timeout); +bigtime_t restore_syscall_restart_timeout(void); + #endif // NET_UTILITY_H From bonefish at mail.berlios.de Sun Feb 17 17:27:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 17:27:17 +0100 Subject: [Haiku-commits] r23985 - haiku/trunk/src/tests/system/kernel Message-ID: <200802171627.m1HGRHmj030454@sheep.berlios.de> Author: bonefish Date: 2008-02-17 17:27:17 +0100 (Sun, 17 Feb 2008) New Revision: 23985 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23985&view=rev Added: haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp Modified: haiku/trunk/src/tests/system/kernel/Jamfile Log: Test program for syscall restarts. Only a few syscalls are tested yet. Nested syscall restarts (interrupted syscall in a signal handler) aren't tested yet. Modified: haiku/trunk/src/tests/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/Jamfile 2008-02-17 16:25:07 UTC (rev 23984) +++ haiku/trunk/src/tests/system/kernel/Jamfile 2008-02-17 16:27:17 UTC (rev 23985) @@ -32,6 +32,8 @@ SimpleTest select_check : select_check.cpp ; SimpleTest select_close_test : select_close_test.cpp ; +SimpleTest syscall_restart_test : syscall_restart_test.cpp : network ; + SetSupportedPlatformsForTarget syscall_time : $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ; SimpleTest syscall_time : syscall_time.cpp ; Added: haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp 2008-02-17 16:25:07 UTC (rev 23984) +++ haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp 2008-02-17 16:27:17 UTC (rev 23985) @@ -0,0 +1,689 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +enum run_mode { + RUN_IGNORE_SIGNAL, + RUN_HANDLE_SIGNAL, + RUN_HANDLE_SIGNAL_RESTART +}; + + +class Test { +public: + Test(const char* name) + : fName(name) + { + } + + virtual ~Test() + { + } + + bool Run(run_mode mode) + { + fRunMode = mode; + fSignalHandlerCalled = false; + + status_t error = Prepare(); + if (error != B_OK) + return Error("Failed to prepare test: %s", strerror(error)); + + thread_id thread = spawn_thread(_ThreadEntry, fName, B_NORMAL_PRIORITY, + this); + if (thread < 0) + return Error("Failed to spawn thread: %s\n", strerror(thread)); + + resume_thread(thread); + + // ... + // * interrupt without restart + // * interrupt with restart + + snooze(100000); + kill(thread, SIGINT); + + PrepareFinish(); + + status_t result; + wait_for_thread(thread, &result); + + if (result != (Interrupted() ? B_INTERRUPTED : B_OK)) { + return Error("Unexpected syscall return value: %s\n", + strerror(result)); + } + + if ((RunMode() == RUN_IGNORE_SIGNAL) == fSignalHandlerCalled) { + if (RunMode() == RUN_IGNORE_SIGNAL) + return Error("Handler was called but shouldn't have been!"); + else + return Error("Handler was not called!"); + } + + return Finish(Interrupted()); + } + + void Run() + { + printf("%s\n", fName); + + struct { + const char* name; + run_mode mode; + } tests[] = { + { "ignore signal", RUN_IGNORE_SIGNAL }, + { "handle signal no restart", RUN_HANDLE_SIGNAL }, + { "handle signal restart", RUN_HANDLE_SIGNAL_RESTART }, + {} + }; + + for (int i = 0; tests[i].name != NULL; i++) { + printf(" %-30s: ", tests[i].name); + fflush(stdout); + ClearError(); + if (Run(tests[i].mode)) + printf("ok\n"); + else + printf("failed (%s)\n", fError); + + Cleanup(); + } + } + + run_mode RunMode() const { return fRunMode; } + bool Interrupted() const { return RunMode() == RUN_HANDLE_SIGNAL; } + bigtime_t TimeWaited() const { return fTimeWaited; } + +protected: + virtual status_t Prepare() + { + return B_OK; + } + + virtual status_t DoSyscall() = 0; + + virtual void HandleSignal() + { + } + + virtual void PrepareFinish() + { + } + + virtual bool Finish(bool interrupted) + { + return true; + } + + virtual void Cleanup() + { + } + + bool Error(const char* format,...) + { + va_list args; + va_start(args, format); + vsnprintf(fError, sizeof(fError), format, args); + va_end(args); + + return false; + } + + bool Check(bool condition, const char* format,...) + { + if (condition) + return true; + + va_list args; + va_start(args, format); + vsnprintf(fError, sizeof(fError), format, args); + va_end(args); + + return false; + } + + void ClearError() + { + fError[0] = '\0'; + } + +private: + static status_t _ThreadEntry(void* data) + { + return ((Test*)data)->_TestThread(); + } + + static void _SignalHandler(int signal, char* userData) + { + Test* self = (Test*)userData; + + self->fSignalHandlerCalled = true; + self->HandleSignal(); + } + + status_t _TestThread() + { + // install handler + struct sigaction action; + if (RunMode() == RUN_IGNORE_SIGNAL) + action.sa_handler = SIG_IGN; + else + action.sa_handler = (void (*)(int))_SignalHandler; + + action.sa_flags = RunMode() == RUN_HANDLE_SIGNAL_RESTART + ? SA_RESTART : 0; + + sigemptyset(&action.sa_mask); + action.sa_userdata = this; + + sigaction(SIGINT, &action, NULL); + + bigtime_t startTime = system_time(); + status_t status = DoSyscall(); + fTimeWaited = system_time() - startTime; + + return status; + } + +private: + const char* fName; + run_mode fRunMode; + bool fSignalHandlerCalled; + bigtime_t fTimeWaited; + char fError[1024]; +}; + + +class SnoozeTest : public Test { +public: + SnoozeTest() + : Test("snooze") + { + } + + virtual status_t DoSyscall() + { + return snooze(1000000); + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(TimeWaited() < 200000, "waited too long"); + + return Check(TimeWaited() > 900000 && TimeWaited() < 1100000, + "waited %lld us instead of 1000000 us", TimeWaited()); + } +}; + + +class ReadTest : public Test { +public: + ReadTest() + : Test("read") + { + } + + virtual status_t Prepare() + { + fBytesRead = -1; + fFDs = (int[2]){-1, -1}; + + if (pipe(fFDs) != 0) + return errno; + + return B_OK; + } + + virtual status_t DoSyscall() + { + char buffer[256]; + fBytesRead = read(fFDs[0], buffer, sizeof(buffer)); + + return fBytesRead < 0 ? errno : B_OK; + } + + virtual void PrepareFinish() + { + write(fFDs[1], "Ingo", 4); + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(fBytesRead < 0, "unexpected read"); + + return Check(fBytesRead == 4, "should have read 4 bytes, read only %ld " + "bytes", fBytesRead); + } + + virtual void Cleanup() + { + close(fFDs[0]); + close(fFDs[1]); + } + +private: + bigtime_t fTimeWaited; + ssize_t fBytesRead; + int fFDs[2]; +}; + + +class WriteTest : public Test { +public: + WriteTest() + : Test("write") + { + } + + virtual status_t Prepare() + { + fBytesWritten = -1; + fFDs = (int[2]){-1, -1}; + + if (pipe(fFDs) != 0) + return errno; + + // fill pipe + fcntl(fFDs[1], F_SETFL, O_NONBLOCK); + while (write(fFDs[1], "a", 1) == 1); + + return B_OK; + } + + virtual status_t DoSyscall() + { + // blocking wait + fcntl(fFDs[1], F_SETFL, 0); + fBytesWritten = write(fFDs[1], "Ingo", 4); + + return fBytesWritten < 0 ? errno : B_OK; + } + + virtual void PrepareFinish() + { + char buffer[256]; + read(fFDs[0], buffer, sizeof(buffer)); + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(fBytesWritten < 0, "unexpected write"); + + return Check(fBytesWritten == 4, "should have written 4 bytes, wrote only %ld " + "bytes", fBytesWritten); + } + + virtual void Cleanup() + { + close(fFDs[0]); + close(fFDs[1]); + } + +private: + ssize_t fBytesWritten; + int fFDs[2]; +}; + + +class AcquireSwitchSemTest : public Test { +public: + AcquireSwitchSemTest(bool useSwitch) + : Test(useSwitch ? "switch_sem" : "acquire_sem"), + fSwitch(useSwitch) + { + } + + virtual status_t Prepare() + { + fSemaphore = create_sem(0, "test sem"); + + return (fSemaphore >= 0 ? B_OK : fSemaphore); + } + + virtual status_t DoSyscall() + { + if (fSwitch) + return switch_sem(-1, fSemaphore); + + return acquire_sem(fSemaphore); + } + + virtual void PrepareFinish() + { + release_sem(fSemaphore); + } + +/* + virtual bool Finish(bool interrupted) + { +// int32 semCount = -1; +// get_sem_count(fSemaphore, &semCount); + + if (interrupted) + return true; + + return Check(fBytesWritten == 4, "should have written 4 bytes, wrote only %ld " + "bytes", fBytesWritten); + } +*/ + + virtual void Cleanup() + { + delete_sem(fSemaphore); + } + +protected: + sem_id fSemaphore; + bool fSwitch; +}; + + +class AcquireSwitchSemEtcTest : public Test { +public: + AcquireSwitchSemEtcTest(bool useSwitch) + : Test(useSwitch ? "switch_sem_etc" : "acquire_sem_etc"), + fSwitch(useSwitch) + { + } + + virtual status_t Prepare() + { + fSemaphore = create_sem(0, "test sem"); + + return fSemaphore >= 0 ? B_OK : fSemaphore; + } + + virtual status_t DoSyscall() + { + status_t status; + if (fSwitch) { + status = switch_sem_etc(-1, fSemaphore, 1, B_RELATIVE_TIMEOUT, + 1000000); + } else { + status = acquire_sem_etc(fSemaphore, 1, B_RELATIVE_TIMEOUT, + 1000000); + } + + if (!Interrupted() && status == B_TIMED_OUT) + return B_OK; + + return status; + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(TimeWaited() < 200000, "waited too long"); + + return Check(TimeWaited() > 900000 && TimeWaited() < 1100000, + "waited %lld us instead of 1000000 us", TimeWaited()); + } + + virtual void Cleanup() + { + delete_sem(fSemaphore); + } + +protected: + sem_id fSemaphore; + bool fSwitch; +}; + + +class AcceptTest : public Test { +public: + AcceptTest() + : Test("accept") + { + } + + virtual status_t Prepare() + { + fAcceptedSocket = -1; + + fServerSocket = socket(AF_INET, SOCK_STREAM, 0); + if (fServerSocket < 0) { + fprintf(stderr, "Could not open server socket: %s\n", + strerror(errno)); + return errno; + } + + int reuse = 1; + if (setsockopt(fServerSocket, SOL_SOCKET, SO_REUSEADDR, &reuse, + sizeof(int)) == -1) { + fprintf(stderr, "Could not make server socket reusable: %s\n", + strerror(errno)); + return errno; + } + + memset(&fServerAddress, 0, sizeof(sockaddr_in)); + fServerAddress.sin_family = AF_INET; + fServerAddress.sin_addr.s_addr = INADDR_LOOPBACK; + + if (bind(fServerSocket, (struct sockaddr *)&fServerAddress, + sizeof(struct sockaddr)) == -1) { + fprintf(stderr, "Could not bind server socket: %s\n", + strerror(errno)); + return errno; + } + + socklen_t length = sizeof(sockaddr_in); + getsockname(fServerSocket, (sockaddr*)&fServerAddress, + &length); + + if (listen(fServerSocket, 10) == -1) { + fprintf(stderr, "Could not listen on server socket: %s\n", + strerror(errno)); + return errno; + } + + return B_OK; + } + + virtual status_t DoSyscall() + { + sockaddr_in clientAddress; + socklen_t length = sizeof(struct sockaddr_in); + + fAcceptedSocket = accept(fServerSocket, + (struct sockaddr *)&clientAddress, &length); + if (fAcceptedSocket == -1) + return errno; + + return B_OK; + } + + virtual void PrepareFinish() + { + if (Interrupted()) + return; + + int clientSocket = socket(AF_INET, SOCK_STREAM, 0); + if (clientSocket == -1) { + fprintf(stderr, "Could not open client socket: %s\n", + strerror(errno)); + return; + } + + if (connect(clientSocket, (struct sockaddr *)&fServerAddress, + sizeof(struct sockaddr)) == -1) { + fprintf(stderr, "Could not connect to server socket: %s\n", + strerror(errno)); + } + + close(clientSocket); + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(fAcceptedSocket < 0, "got socket"); + + return Check(fAcceptedSocket >= 0, "got no socket"); + } + + virtual void Cleanup() + { + close(fAcceptedSocket); + close(fServerSocket); + } + +protected: + int fServerSocket; + sockaddr_in fServerAddress; + int fAcceptedSocket; +}; + + +class ReceiveTest : public Test { +public: + ReceiveTest() + : Test("recv") + { + } + + virtual status_t Prepare() + { + fBytesRead = -1; + fAcceptedSocket = -1; + fClientSocket = -1; + + fServerSocket = socket(AF_INET, SOCK_STREAM, 0); + if (fServerSocket < 0) { + fprintf(stderr, "Could not open server socket: %s\n", + strerror(errno)); + return errno; + } + + int reuse = 1; + if (setsockopt(fServerSocket, SOL_SOCKET, SO_REUSEADDR, &reuse, + sizeof(int)) == -1) { + fprintf(stderr, "Could not make server socket reusable: %s\n", + strerror(errno)); + return errno; + } + + memset(&fServerAddress, 0, sizeof(sockaddr_in)); + fServerAddress.sin_family = AF_INET; + fServerAddress.sin_addr.s_addr = INADDR_LOOPBACK; + + if (bind(fServerSocket, (struct sockaddr *)&fServerAddress, + sizeof(struct sockaddr)) == -1) { + fprintf(stderr, "Could not bind server socket: %s\n", + strerror(errno)); + return errno; + } + + socklen_t length = sizeof(sockaddr_in); + getsockname(fServerSocket, (sockaddr*)&fServerAddress, + &length); + + if (listen(fServerSocket, 10) == -1) { + fprintf(stderr, "Could not listen on server socket: %s\n", + strerror(errno)); + return errno; + } + + fClientSocket = socket(AF_INET, SOCK_STREAM, 0); + if (fClientSocket == -1) { + fprintf(stderr, "Could not open client socket: %s\n", + strerror(errno)); + return errno; + } + + fcntl(fClientSocket, F_SETFL, O_NONBLOCK); + + if (connect(fClientSocket, (struct sockaddr *)&fServerAddress, + sizeof(struct sockaddr)) == -1) { + if (errno != EINPROGRESS) { + fprintf(stderr, "Could not connect to server socket: %s\n", + strerror(errno)); + return errno; + } + } + + sockaddr_in clientAddress; + length = sizeof(struct sockaddr_in); + + fAcceptedSocket = accept(fServerSocket, + (struct sockaddr *)&clientAddress, &length); + if (fAcceptedSocket == -1) + return errno; + + fcntl(fClientSocket, F_SETFL, 0); + + snooze(100000); + + return B_OK; + } + + virtual status_t DoSyscall() + { + char buffer[256]; + fBytesRead = recv(fAcceptedSocket, buffer, sizeof(buffer), 0); + + return fBytesRead < 0 ? errno : B_OK; + } + + virtual void PrepareFinish() + { + write(fClientSocket, "Axel", 4); + } + + virtual bool Finish(bool interrupted) + { + if (interrupted) + return Check(fBytesRead < 0, "unexpected read"); + + return Check(fBytesRead == 4, "should have read 4 bytes, read only %ld " + "bytes", fBytesRead); + } + + virtual void Cleanup() + { + close(fAcceptedSocket); + close(fServerSocket); + close(fClientSocket); + } + +protected: + int fServerSocket; + sockaddr_in fServerAddress; + int fAcceptedSocket; + int fClientSocket; + ssize_t fBytesRead; +}; + + +int +main() +{ + Test* tests[] = { +/* new SnoozeTest, + new ReadTest, + new WriteTest, + new AcquireSwitchSemTest(false), + new AcquireSwitchSemTest(true), + new AcquireSwitchSemEtcTest(false), + new AcquireSwitchSemEtcTest(true), + new AcceptTest, +*/ new ReceiveTest, + NULL + }; + + for (int i = 0; tests[i] != NULL; i++) + tests[i]->Run(); + + return 0; +} From axeld at mail.berlios.de Sun Feb 17 17:38:08 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Feb 2008 17:38:08 +0100 Subject: [Haiku-commits] r23986 - haiku/trunk/src/system/runtime_loader Message-ID: <200802171638.m1HGc8cg031204@sheep.berlios.de> Author: axeld Date: 2008-02-17 17:38:07 +0100 (Sun, 17 Feb 2008) New Revision: 23986 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23986&view=rev Modified: haiku/trunk/src/system/runtime_loader/elf.cpp haiku/trunk/src/system/runtime_loader/runtime_loader.c haiku/trunk/src/system/runtime_loader/runtime_loader_private.h Log: bonefish+axeld: The runtime loader did not correctly resolve %A correctly with the actual normalized program path. IOW it would not work correctly with symlinks to applications that had their own lib directory. Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-17 16:27:17 UTC (rev 23985) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-02-17 16:38:07 UTC (rev 23986) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2002, Manuel J. Petit. All rights reserved. @@ -263,8 +263,21 @@ } +static const char * +get_program_path() +{ + for (image_t *image = sLoadedImages.head; image; image = image->next) { + if (image->type == B_APP_IMAGE) + return image->path; + } + + return NULL; +} + + static status_t -parse_elf_header(struct Elf32_Ehdr *eheader, int32 *_pheaderSize, int32 *_sheaderSize) +parse_elf_header(struct Elf32_Ehdr *eheader, int32 *_pheaderSize, + int32 *_sheaderSize) { if (memcmp(eheader->e_ident, ELF_MAGIC, 4) != 0) return B_NOT_AN_EXECUTABLE; @@ -990,7 +1003,7 @@ strlcpy(path, name, sizeof(path)); // Try to load explicit image path first - fd = open_executable(path, type, rpath); + fd = open_executable(path, type, rpath, get_program_path()); if (fd < 0) { FATAL("cannot open file %s\n", path); KTRACE("rld: load_container(\"%s\"): failed to open file", name); Modified: haiku/trunk/src/system/runtime_loader/runtime_loader.c =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-02-17 16:27:17 UTC (rev 23985) +++ haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-02-17 16:38:07 UTC (rev 23986) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2002, Manuel J. Petit. All rights reserved. @@ -82,8 +82,8 @@ static int -try_open_executable(const char *dir, int dirLength, const char *name, char *path, - size_t pathLength) +try_open_executable(const char *dir, int dirLength, const char *name, + const char *programPath, char *path, size_t pathLength) { size_t nameLength = strlen(name); struct stat stat; @@ -93,18 +93,19 @@ if (dirLength > 0) { char *buffer = path; + if (programPath == NULL) + programPath = gProgramArgs->program_path; + if (dirLength >= 2 && strncmp(dir, "%A", 2) == 0) { // Replace %A with current app folder path (of course, // this must be the first part of the path) - // ToDo: Maybe using first image info is better suited than - // gProgamArgs->program_path here? - char *lastSlash = strrchr(gProgramArgs->program_path, '/'); + char *lastSlash = strrchr(programPath, '/'); int bytesCopied; // copy what's left (when the application name is removed) if (lastSlash != NULL) { - strlcpy(buffer, gProgramArgs->program_path, - min((int)pathLength, lastSlash + 1 - gProgramArgs->program_path)); + strlcpy(buffer, programPath, + min((int)pathLength, lastSlash + 1 - programPath)); } else strlcpy(buffer, ".", pathLength); @@ -160,7 +161,8 @@ static int search_executable_in_path_list(const char *name, const char *pathList, - int pathListLen, char *pathBuffer, size_t pathBufferLength) + int pathListLen, const char *programPath, char *pathBuffer, + size_t pathBufferLength) { const char *pathListEnd = pathList + pathListLen; status_t status = B_ENTRY_NOT_FOUND; @@ -176,8 +178,8 @@ while (pathEnd < pathListEnd && *pathEnd != ':') pathEnd++; - fd = try_open_executable(pathList, pathEnd - pathList, name, pathBuffer, - pathBufferLength); + fd = try_open_executable(pathList, pathEnd - pathList, name, + programPath, pathBuffer, pathBufferLength); if (fd >= 0) { // see if it's a dir struct stat stat; @@ -199,7 +201,8 @@ int -open_executable(char *name, image_type type, const char *rpath) +open_executable(char *name, image_type type, const char *rpath, + const char *programPath) { const char *paths; char buffer[PATH_MAX]; @@ -214,7 +217,7 @@ // Even though ELF specs don't say this, we give shared libraries // another chance and look them up in the usual search paths - at // least that seems to be what BeOS does, and since it doesn't hurt... - paths = strrchr(name, '/'); + paths = strrchr(name, '/') + 1; memmove(name, paths, strlen(paths) + 1); } @@ -229,11 +232,11 @@ // If there is no ';', we set only secondList to simplify things. if (firstList) { fd = search_executable_in_path_list(name, firstList, - semicolon - firstList, buffer, sizeof(buffer)); + semicolon - firstList, programPath, buffer, sizeof(buffer)); } if (fd < 0) { fd = search_executable_in_path_list(name, secondList, - strlen(secondList), buffer, sizeof(buffer)); + strlen(secondList), programPath, buffer, sizeof(buffer)); } } @@ -242,13 +245,13 @@ paths = search_path_for_type(type); if (paths) { fd = search_executable_in_path_list(name, paths, strlen(paths), - buffer, sizeof(buffer)); + programPath, buffer, sizeof(buffer)); } } if (fd >= 0) { // we found it, copy path! - TRACE(("runtime_loader: open_container(%s): found at %s\n", name, buffer)); + TRACE(("runtime_loader: open_executable(%s): found at %s\n", name, buffer)); strlcpy(name, buffer, PATH_MAX); } @@ -278,7 +281,7 @@ strlcpy(path, name, sizeof(path)); - fd = open_executable(path, B_APP_IMAGE, NULL); + fd = open_executable(path, B_APP_IMAGE, NULL, NULL); if (fd < B_OK) return fd; Modified: haiku/trunk/src/system/runtime_loader/runtime_loader_private.h =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader_private.h 2008-02-17 16:27:17 UTC (rev 23985) +++ haiku/trunk/src/system/runtime_loader/runtime_loader_private.h 2008-02-17 16:38:07 UTC (rev 23986) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2002, Manuel J. Petit. All rights reserved. @@ -23,7 +23,8 @@ #endif int runtime_loader(void *arg); -int open_executable(char *name, image_type type, const char *rpath); +int open_executable(char *name, image_type type, const char *rpath, + const char *programPath); status_t test_executable(const char *path, uid_t user, gid_t group, char *starter); From axeld at mail.berlios.de Sun Feb 17 17:40:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Feb 2008 17:40:03 +0100 Subject: [Haiku-commits] r23987 - haiku/trunk/src/servers/net Message-ID: <200802171640.m1HGe3P5031328@sheep.berlios.de> Author: axeld Date: 2008-02-17 17:40:03 +0100 (Sun, 17 Feb 2008) New Revision: 23987 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23987&view=rev Modified: haiku/trunk/src/servers/net/Services.cpp Log: bonefish+axeld: * the net_server leaked file descriptors for every opened session. Modified: haiku/trunk/src/servers/net/Services.cpp =================================================================== --- haiku/trunk/src/servers/net/Services.cpp 2008-02-17 16:38:07 UTC (rev 23986) +++ haiku/trunk/src/servers/net/Services.cpp 2008-02-17 16:40:03 UTC (rev 23987) @@ -521,6 +521,9 @@ exit(1); // we'll never trespass here + } else { + // the server does not need the socket anymore + close(socket); } // TODO: make sure child started successfully... From jonas at kirilla.com Sun Feb 17 16:45:45 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Sun, 17 Feb 2008 16:45:45 +0100 CET Subject: [Haiku-commits] r23977 - haiku/trunk/src/apps/mail In-Reply-To: <1620958079-BeMail@laptop> Message-ID: <1013108252-BeMail@kirilla> "Fran?ois Revol" wrote: > > Author: kirilla > > Date: 2008-02-17 15:36:01 +0100 (Sun, 17 Feb 2008) > > New Revision: 23977 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23977&view=rev > > > > Modified: > > haiku/trunk/src/apps/mail/MailWindow.cpp > > Log: > > 0L constant typo? Remove menu item before deleting it. > > No it's not a typo, it's a gccish which means Long, just like LL > means > long long, to avoid having to do a cast. > A standard way of doing that would be using INT32_C(0), see > http://linux.die.net/man/3/int32_c > (not sure we have all of them, BeOS didn't have any) Sorry about that. Does it matter enough to put the 0L back? /Jonas. From axeld at pinc-software.de Sun Feb 17 18:17:49 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 17 Feb 2008 18:17:49 +0100 CET Subject: [Haiku-commits] r23985 - haiku/trunk/src/tests/system/kernel In-Reply-To: <200802171627.m1HGRHmj030454@sheep.berlios.de> Message-ID: <16547430326-BeMail@zon> bonefish at BerliOS wrote: > + Test* tests[] = { > +/* new SnoozeTest, > + new ReadTest, > + new WriteTest, > + new AcquireSwitchSemTest(false), > + new AcquireSwitchSemTest(true), > + new AcquireSwitchSemEtcTest(false), > + new AcquireSwitchSemEtcTest(true), > + new AcceptTest, > +*/ new ReceiveTest, > + NULL > + }; There still seem to be some tests commented out... :-) And in r23970, unistd.cpp: > +#include > fssh_ssize_t > fssh_write_pos(int fd, fssh_off_t pos, const void *buffer, > fssh_size_t count) Debugging leftover. I hope you all had a nice trip back :-) Bye, Axel. From mmu_man at mail.berlios.de Sun Feb 17 18:53:55 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 17 Feb 2008 18:53:55 +0100 Subject: [Haiku-commits] r23988 - haiku/trunk/src/tools/fs_shell Message-ID: <200802171753.m1HHrt1d008163@sheep.berlios.de> Author: mmu_man Date: 2008-02-17 18:53:54 +0100 (Sun, 17 Feb 2008) New Revision: 23988 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23988&view=rev Modified: haiku/trunk/src/tools/fs_shell/stat.cpp Log: Fix build on BeOS host, seems it was trying to instanciate a struct stat instead... Modified: haiku/trunk/src/tools/fs_shell/stat.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/stat.cpp 2008-02-17 16:40:03 UTC (rev 23987) +++ haiku/trunk/src/tools/fs_shell/stat.cpp 2008-02-17 17:53:54 UTC (rev 23988) @@ -36,7 +36,7 @@ // Use the _kern_read_stat() defined in libroot on BeOS incompatible // systems. Required for support for opening symlinks. #if __BEOS__ - if (stat(path, &st) < 0) + if (::stat(path, &st) < 0) return -1; #else status_t error = _kern_read_stat(-1, path, true, &st, sizeof(st)); From bonefish at mail.berlios.de Sun Feb 17 19:05:50 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 19:05:50 +0100 Subject: [Haiku-commits] r23989 - haiku/trunk/headers/private/kernel Message-ID: <200802171805.m1HI5ode019779@sheep.berlios.de> Author: bonefish Date: 2008-02-17 19:05:49 +0100 (Sun, 17 Feb 2008) New Revision: 23989 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23989&view=rev Modified: haiku/trunk/headers/private/kernel/syscall_restart.h Log: Converting relative timeouts into absolute ones is fine in principle, but there's a special handling for 0 us relative timeouts. Syscalls usually return B_WOULD_BLOCK instead of B_TIMED_OUT in this case, and callers might explicitely check for it. Hence we don't convert 0 us timeouts anymore. gdb works again. Modified: haiku/trunk/headers/private/kernel/syscall_restart.h =================================================================== --- haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-17 17:53:54 UTC (rev 23988) +++ haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-17 18:05:49 UTC (rev 23989) @@ -30,19 +30,23 @@ syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) { // If restarted, get the timeout from the restart parameters. Otherwise - // convert relative timeout to an absolute one. + // convert relative timeout to an absolute one. Note that we preserve + // relative 0 us timeouts, so that the syscall can still decide whether to + // return B_WOULD_BLOCK instead of B_TIMED_OUT. struct thread* thread = thread_get_current_thread(); - if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) + if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) { timeout = *(bigtime_t*)thread->syscall_restart.parameters; - else if ((flags & B_RELATIVE_TIMEOUT) != 0) { - timeout += system_time(); - if (timeout < 0) - timeout = B_INFINITE_TIMEOUT; + if (timeout != 0 && (flags & B_RELATIVE_TIMEOUT) != 0) + flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; + } else if ((flags & B_RELATIVE_TIMEOUT) != 0) { + if (timeout != 0) { + timeout += system_time(); + if (timeout < 0) + timeout = B_INFINITE_TIMEOUT; + + flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; + } } - - // any timeout is absolute at this point - if ((flags & B_RELATIVE_TIMEOUT) != 0) - flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; } From bonefish at mail.berlios.de Sun Feb 17 19:07:27 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 17 Feb 2008 19:07:27 +0100 Subject: [Haiku-commits] r23990 - in haiku/trunk/src: tests/system/kernel tools/fs_shell Message-ID: <200802171807.m1HI7RAR022165@sheep.berlios.de> Author: bonefish Date: 2008-02-17 19:07:25 +0100 (Sun, 17 Feb 2008) New Revision: 23990 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23990&view=rev Modified: haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp haiku/trunk/src/tools/fs_shell/unistd.cpp Log: Removed debugging leftover. Modified: haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp 2008-02-17 18:05:49 UTC (rev 23989) +++ haiku/trunk/src/tests/system/kernel/syscall_restart_test.cpp 2008-02-17 18:07:25 UTC (rev 23990) @@ -670,7 +670,7 @@ main() { Test* tests[] = { -/* new SnoozeTest, + new SnoozeTest, new ReadTest, new WriteTest, new AcquireSwitchSemTest(false), @@ -678,7 +678,7 @@ new AcquireSwitchSemEtcTest(false), new AcquireSwitchSemEtcTest(true), new AcceptTest, -*/ new ReceiveTest, + new ReceiveTest, NULL }; Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-17 18:05:49 UTC (rev 23989) +++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-17 18:07:25 UTC (rev 23990) @@ -344,7 +344,6 @@ } -#include fssh_ssize_t fssh_write_pos(int fd, fssh_off_t pos, const void *buffer, fssh_size_t count) { From ingo_weinhold at gmx.de Sun Feb 17 19:14:40 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 17 Feb 2008 19:14:40 +0100 Subject: [Haiku-commits] r23985 - haiku/trunk/src/tests/system/kernel In-Reply-To: <16547430326-BeMail@zon> References: <16547430326-BeMail@zon> Message-ID: <20080217191440.1693.3@knochen-vm.1203248001.fake> On 2008-02-17 at 18:17:49 [+0100], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > + Test* tests[] = { > > +/* new SnoozeTest, > > + new ReadTest, > > + new WriteTest, > > + new AcquireSwitchSemTest(false), > > + new AcquireSwitchSemTest(true), > > + new AcquireSwitchSemEtcTest(false), > > + new AcquireSwitchSemEtcTest(true), > > + new AcceptTest, > > +*/ new ReceiveTest, > > + NULL > > + }; > > There still seem to be some tests commented out... :-) > > And in r23970, unistd.cpp: > > > +#include > > fssh_ssize_t > > fssh_write_pos(int fd, fssh_off_t pos, const void *buffer, > > fssh_size_t count) > > Debugging leftover. Thanks, removed. > I hope you all had a nice trip back :-) Well enough, thank! I don't recall much of it, though... :-) CU, Ingo From marcusoverhagen at mail.berlios.de Sun Feb 17 20:14:50 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 17 Feb 2008 20:14:50 +0100 Subject: [Haiku-commits] r23991 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802171914.m1HJEoFd030603@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-17 20:14:50 +0100 (Sun, 17 Feb 2008) New Revision: 23991 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23991&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Log: gcc4 build fix Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-17 18:07:25 UTC (rev 23990) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-17 19:14:50 UTC (rev 23991) @@ -395,7 +395,7 @@ // function returns, as well as the arguments of the entry function stackTop -= codeSize; - if (user_memcpy((void *)stackTop, x86_userspace_thread_exit, codeSize) < B_OK) + if (user_memcpy((void *)stackTop, (const void *)&x86_userspace_thread_exit, codeSize) < B_OK) return B_BAD_ADDRESS; args[0] = stackTop; From marcusoverhagen at mail.berlios.de Sun Feb 17 20:18:32 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 17 Feb 2008 20:18:32 +0100 Subject: [Haiku-commits] r23992 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200802171918.m1HJIWDq030940@sheep.berlios.de> Author: marcusoverhagen Date: 2008-02-17 20:18:31 +0100 (Sun, 17 Feb 2008) New Revision: 23992 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23992&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Log: gcc4 build fix Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-17 19:14:50 UTC (rev 23991) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-17 19:18:31 UTC (rev 23992) @@ -481,7 +481,7 @@ userStack -= ((uint32)i386_end_return_from_signal + 3 - (uint32)i386_return_from_signal) / 4; signalCode = userStack; - status = user_memcpy(signalCode, i386_return_from_signal, + status = user_memcpy(signalCode, (const void *)&i386_return_from_signal, ((uint32)i386_end_return_from_signal - (uint32)i386_return_from_signal)); if (status < B_OK) From mmlr at mail.berlios.de Sun Feb 17 20:47:30 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 17 Feb 2008 20:47:30 +0100 Subject: [Haiku-commits] r23993 - haiku/trunk/build/jam Message-ID: <200802171947.m1HJlUSC001465@sheep.berlios.de> Author: mmlr Date: 2008-02-17 20:47:29 +0100 (Sun, 17 Feb 2008) New Revision: 23993 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23993&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add bison datafiles yacc.c, c.m4 and c++.m4 to /etc on the image. They are needed to build Haiku. Also fixes #1783. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-17 19:18:31 UTC (rev 23992) +++ haiku/trunk/build/jam/HaikuImage 2008-02-17 19:47:29 UTC (rev 23993) @@ -364,6 +364,10 @@ = [ FDirName $(HAIKU_TOP) src bin bison data m4sugar ] ; AddFilesToHaikuImage beos etc m4sugar : m4sugar.m4 ; +local bisonFiles = "yacc.c" "c.m4" "c++.m4" ; +SEARCH on $(bisonFiles) = [ FDirName $(HAIKU_TOP) src bin bison data ] ; +AddFilesToHaikuImage beos etc : $(bisonFiles) ; + # boot loader AddFilesToHaikuImage beos system : zbeos ; From simontaylor1 at ntlworld.com Sun Feb 17 21:16:08 2008 From: simontaylor1 at ntlworld.com (Simon Taylor) Date: Sun, 17 Feb 2008 20:16:08 +0000 Subject: [Haiku-commits] r23947 - in haiku/trunk/src: build/libbe/storage/mime tools/fs_shell In-Reply-To: <20080212080255.M75379@mlotz.ch> References: <200802120054.m1C0s4Hn019625@sheep.berlios.de> <2801134143-BeMail@primary> <20080212080255.M75379@mlotz.ch> Message-ID: <47B89608.3070408@ntlworld.com> Michael Lotz wrote: > On Mon, 11 Feb 2008 22:08:51 -0500, Ryan Leavengood wrote >> On Feb 11, 2008 8:01 PM, Michael Lotz wrote: >>> Well, that's all what I've come up with after a Haiku session with an >>> uptime of more than 5 hours, compiling my first haiku-image under Haiku >>> from a tree checked out under Haiku. >> Um, wow! I'm thinking this might be important enough to post about on >> the Haiku web site! ;) > > Well, it's certainly a nice milestone (if we even want to call it that), but I > don't think we need to hype it. Haiku's just become pretty stable and nice to > work/develop on. But it's certainly not there yet. As I said there are > numerous memory leaks (or maybe it's just the new allocator who messes up > things...) that prevent doing everything in one go. So we're not exactly > selfhosting, just close to it. I'll certainly be mentioning this in my next Activity Update, coming early next week. I'll be sure to attach the disclaimers to it though. Simon From mmlr at mail.berlios.de Mon Feb 18 02:04:20 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 18 Feb 2008 02:04:20 +0100 Subject: [Haiku-commits] r23994 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200802180104.m1I14KSY017598@sheep.berlios.de> Author: mmlr Date: 2008-02-18 02:04:19 +0100 (Mon, 18 Feb 2008) New Revision: 23994 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23994&view=rev Modified: haiku/trunk/headers/private/kernel/heap.h haiku/trunk/src/system/kernel/heap.cpp Log: Use a dedicated heap to allocate everything that is needed during heap growth. This eliminates the edge case where the grow thread would not be able to create a new area because no memory could be allocated for the allocation of the area. As this case cannot happen anymore, it is also not possible to deadlock in memalign. Therefore the timeout (which would only have prevented the deadlock but wouldn't have solved the edge case anyway) has been removed too. Add options to dump the dedicated grow heap and to only print the current heap count to the "heap" debugger command. Modified: haiku/trunk/headers/private/kernel/heap.h =================================================================== --- haiku/trunk/headers/private/kernel/heap.h 2008-02-17 19:47:29 UTC (rev 23993) +++ haiku/trunk/headers/private/kernel/heap.h 2008-02-18 01:04:19 UTC (rev 23994) @@ -11,12 +11,13 @@ #include // allocate 16MB initial heap for the kernel -#define INITIAL_HEAP_SIZE 16 * 1024 * 1024 +#define INITIAL_HEAP_SIZE 16 * 1024 * 1024 // grow by another 8MB each time the heap runs out of memory -#define HEAP_GROW_SIZE 8 * 1024 * 1024 +#define HEAP_GROW_SIZE 8 * 1024 * 1024 +// allocate a dedicated 2MB area for dynamic growing +#define HEAP_DEDICATED_GROW_SIZE 2 * 1024 * 1024 - #ifdef __cplusplus extern "C" { #endif Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-17 19:47:29 UTC (rev 23993) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-18 01:04:19 UTC (rev 23994) @@ -83,6 +83,8 @@ static heap_allocator *sHeapList = NULL; static heap_allocator *sLastGrowRequest = NULL; +static heap_allocator *sGrowHeap = NULL; +static thread_id sHeapGrowThread = -1; static sem_id sHeapGrowSem = -1; static sem_id sHeapGrownNotify = -1; @@ -209,6 +211,26 @@ static int dump_heap_list(int argc, char **argv) { + if (argc == 2) { + if (strcmp(argv[1], "grow") == 0) { + // only dump dedicated grow heap info + dprintf("dedicated grow heap:\n"); + dump_allocator(sGrowHeap); + } else if (strcmp(argv[1], "stats") == 0) { + uint32 heapCount = 0; + heap_allocator *heap = sHeapList; + while (heap) { + heapCount++; + heap = heap->next; + } + + dprintf("current heap count: %ld\n", heapCount); + } else + print_debugger_command_usage(argv[0]); + + return 0; + } + heap_allocator *heap = sHeapList; while (heap) { dump_allocator(heap); @@ -707,7 +729,7 @@ TRACE(("memalign(): asked to allocate %lu bytes, returning pointer %p\n", size, address)); - if (heap->next == NULL) { + if (heap->next == NULL && shouldGrow) { // suggest growing if we are the last heap and we have // less than three free pages left *shouldGrow = (heap->free_pages == NULL @@ -998,7 +1020,11 @@ sHeapList = heap_attach(base, size, false); // set up some debug commands - add_debugger_command("heap", &dump_heap_list, "Dump stats about the kernel heap(s)"); + add_debugger_command_etc("heap", &dump_heap_list, + "Dump infos about the kernel heap(s)", "[(\"grow\" | \"stats\")]\n" + "Dump infos about the kernel heap(s). If \"grow\" is specified, only\n" + "infos about the dedicated grow heap are printed. If \"stats\" is\n" + "given as the argument, currently only the heap count is printed\n", 0); #if KERNEL_HEAP_LEAK_CHECK add_debugger_command_etc("allocations", &dump_allocations, "Dump current allocations", "[(\"team\" | \"thread\") ] [\"stats\"]\n" @@ -1041,14 +1067,31 @@ status_t heap_init_post_thread() { - thread_id thread = spawn_kernel_thread(heap_grow_thread, "heap grower", + void *dedicated = NULL; + area_id area = create_area("heap dedicated grow", &dedicated, + B_ANY_KERNEL_BLOCK_ADDRESS, HEAP_DEDICATED_GROW_SIZE, B_FULL_LOCK, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + if (area < 0) { + panic("heap_init_post_thread(): cannot allocate dedicated grow memory\n"); + return area; + } + + sGrowHeap = heap_attach((addr_t)dedicated, HEAP_DEDICATED_GROW_SIZE, true); + if (sGrowHeap == NULL) { + panic("heap_init_post_thread(): failed to attach dedicated grow heap\n"); + delete_area(area); + return B_ERROR; + } + + sHeapGrowThread = spawn_kernel_thread(heap_grow_thread, "heap grower", B_URGENT_PRIORITY, NULL); - if (thread < 0) { + if (sHeapGrowThread < 0) { panic("heap_init_post_thread(): cannot create heap grow thread\n"); - return B_ERROR; + delete_area(area); + return sHeapGrowThread; } - send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); + send_signal_etc(sHeapGrowThread, SIGCONT, B_DO_NOT_RESCHEDULE); return B_OK; } @@ -1070,6 +1113,17 @@ return NULL; } + if (thread_get_current_thread_id() == sHeapGrowThread) { + // this is the grower thread, allocate from our dedicated memory + void *result = heap_memalign(sGrowHeap, alignment, size, NULL); + if (result == NULL) { + panic("heap: grow thread ran out of dedicated memory!\n"); + return NULL; + } + + return result; + } + heap_allocator *heap = sHeapList; while (heap) { bool shouldGrow = false; @@ -1078,9 +1132,8 @@ // the last heap will or has run out of memory, notify the grower sLastGrowRequest = heap; if (result == NULL) { - // urgent request, do the request and wait for at max 250ms - release_sem(sHeapGrowSem); - acquire_sem_etc(sHeapGrownNotify, 1, B_RELATIVE_TIMEOUT, 250000); + // urgent request, do the request and wait + switch_sem(sHeapGrowSem, sHeapGrownNotify); } else { // not so urgent, just notify the grower release_sem_etc(sHeapGrowSem, 1, B_DO_NOT_RESCHEDULE); @@ -1131,6 +1184,10 @@ heap = heap->next; } + // maybe it was allocated from the dedicated grow heap + if (heap_free(sGrowHeap, address) == B_OK) + return; + panic("free(): free failed for address %p\n", address); } From jackburton at mail.berlios.de Mon Feb 18 09:15:30 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 09:15:30 +0100 Subject: [Haiku-commits] r23995 - haiku/trunk/src/kits/storage Message-ID: <200802180815.m1I8FUkb003816@sheep.berlios.de> Author: jackburton Date: 2008-02-18 09:15:29 +0100 (Mon, 18 Feb 2008) New Revision: 23995 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23995&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: We can't use the be_app looper, since it can be already locked from another thread (for example, when quitting the app/window), and that would cause a deadlock. Fixes bug #1645. Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-02-18 01:04:19 UTC (rev 23994) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-02-18 08:15:29 UTC (rev 23995) @@ -177,14 +177,11 @@ return; BLooper* looper; - if (be_app != NULL) { - looper = be_app; - } else { - // TODO: only have a single global looper! - looper = new BLooper("PathMonitor looper"); - looper->Run(); - fOwnsLooper = true; - } + // TODO: only have a single global looper! + // TODO: Use BLooper::LooperForThread(find_looper(NULL)) ? + looper = new BLooper("PathMonitor looper"); + looper->Run(); + fOwnsLooper = true; looper->Lock(); looper->AddHandler(this); @@ -492,6 +489,7 @@ if (fOwnsLooper) looper->Quit(); + return; } From jackburton at mail.berlios.de Mon Feb 18 09:57:38 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 09:57:38 +0100 Subject: [Haiku-commits] r23996 - in haiku/trunk/src/add-ons/translators: libtiff ppm sgi tga tiff wonderbrush Message-ID: <200802180857.m1I8vcGB007501@sheep.berlios.de> Author: jackburton Date: 2008-02-18 09:57:35 +0100 (Mon, 18 Feb 2008) New Revision: 23996 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23996&view=rev Modified: haiku/trunk/src/add-ons/translators/libtiff/TIFFView.cpp haiku/trunk/src/add-ons/translators/ppm/PPMTranslator.cpp haiku/trunk/src/add-ons/translators/sgi/SGIView.cpp haiku/trunk/src/add-ons/translators/tga/TGAView.cpp haiku/trunk/src/add-ons/translators/tiff/TIFFView.cpp haiku/trunk/src/add-ons/translators/wonderbrush/WonderBrushView.cpp Log: Set the LowColor as ViewColor, so text looks better. Fix a few menufield position/size issues. Use B_PANEL_BACKGROUND_COLOR instead of the raw numbers. Fixes bug #1800. Modified: haiku/trunk/src/add-ons/translators/libtiff/TIFFView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/libtiff/TIFFView.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/libtiff/TIFFView.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -80,6 +80,7 @@ fSettings = settings; SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); BPopUpMenu* menu = new BPopUpMenu("pick compression"); @@ -99,6 +100,9 @@ fCompressionMF = new BMenuField(BRect(20, 50, 215, 70), "compression", "Use Compression:", menu, true); + fCompressionMF->ResizeToPreferred(); + fCompressionMF->SetDivider( + fCompressionMF->StringWidth(fCompressionMF->Label()) + 7); AddChild(fCompressionMF); } Modified: haiku/trunk/src/add-ons/translators/ppm/PPMTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/ppm/PPMTranslator.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/ppm/PPMTranslator.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -436,7 +436,8 @@ uint32 flags) : BView(frame, name, resize, flags) { - SetViewColor(220,220,220,0); + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); mMenu = new BPopUpMenu("Color Space"); mMenu->AddItem(new BMenuItem("None", CSMessage(B_NO_COLOR_SPACE))); mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits", CSMessage(B_RGB32))); @@ -458,6 +459,7 @@ mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits big-endian", CSMessage(B_RGBA15_BIG))); mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits big-endian", CSMessage(B_RGB16))); mField = new BMenuField(BRect(10,110,190,130), "Color Space Field", "Input Color Space", mMenu); + mField->SetDivider(mField->StringWidth(mField->Label()) + 7); mField->SetViewColor(ViewColor()); AddChild(mField); SelectColorSpace(g_settings.out_space); Modified: haiku/trunk/src/add-ons/translators/sgi/SGIView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/sgi/SGIView.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/sgi/SGIView.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -78,6 +78,7 @@ fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); BPopUpMenu* menu = new BPopUpMenu("pick compression"); Modified: haiku/trunk/src/add-ons/translators/tga/TGAView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/tga/TGAView.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/tga/TGAView.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -53,6 +53,7 @@ fSettings = settings; SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); BMessage *pmsg; int32 val; Modified: haiku/trunk/src/add-ons/translators/tiff/TIFFView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/tiff/TIFFView.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/tiff/TIFFView.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -50,7 +50,8 @@ uint32 resize, uint32 flags) : BView(frame, name, resize, flags) { - SetViewColor(220,220,220,0); + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); } // --------------------------------------------------------------- Modified: haiku/trunk/src/add-ons/translators/wonderbrush/WonderBrushView.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/wonderbrush/WonderBrushView.cpp 2008-02-18 08:15:29 UTC (rev 23995) +++ haiku/trunk/src/add-ons/translators/wonderbrush/WonderBrushView.cpp 2008-02-18 08:57:35 UTC (rev 23996) @@ -44,6 +44,7 @@ fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetLowColor(ViewColor()); // figure out where the text ends font_height fh; From jackburton at mail.berlios.de Mon Feb 18 10:01:21 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 10:01:21 +0100 Subject: [Haiku-commits] r23997 - haiku/trunk/src/add-ons/translators Message-ID: <200802180901.m1I91Lgk008078@sheep.berlios.de> Author: jackburton Date: 2008-02-18 10:01:20 +0100 (Mon, 18 Feb 2008) New Revision: 23997 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23997&view=rev Removed: haiku/trunk/src/add-ons/translators/tiff/ Log: removed duplicated and obsolete tiff translator From jackburton at mail.berlios.de Mon Feb 18 10:04:48 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 10:04:48 +0100 Subject: [Haiku-commits] r23998 - in haiku/trunk/src/add-ons/translators: . tiff Message-ID: <200802180904.m1I94mXu008373@sheep.berlios.de> Author: jackburton Date: 2008-02-18 10:04:48 +0100 (Mon, 18 Feb 2008) New Revision: 23998 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23998&view=rev Added: haiku/trunk/src/add-ons/translators/tiff/ Removed: haiku/trunk/src/add-ons/translators/libtiff/ Modified: haiku/trunk/src/add-ons/translators/Jamfile haiku/trunk/src/add-ons/translators/tiff/Jamfile Log: Renamed libtiff to tiff Modified: haiku/trunk/src/add-ons/translators/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/Jamfile 2008-02-18 09:01:20 UTC (rev 23997) +++ haiku/trunk/src/add-ons/translators/Jamfile 2008-02-18 09:04:48 UTC (rev 23998) @@ -7,7 +7,6 @@ SubInclude HAIKU_TOP src add-ons translators ico ; SubInclude HAIKU_TOP src add-ons translators jpeg ; SubInclude HAIKU_TOP src add-ons translators jpeg2000 ; -SubInclude HAIKU_TOP src add-ons translators libtiff ; SubInclude HAIKU_TOP src add-ons translators pcx ; SubInclude HAIKU_TOP src add-ons translators png ; SubInclude HAIKU_TOP src add-ons translators ppm ; @@ -16,4 +15,5 @@ SubInclude HAIKU_TOP src add-ons translators sgi ; SubInclude HAIKU_TOP src add-ons translators stxt ; SubInclude HAIKU_TOP src add-ons translators tga ; +SubInclude HAIKU_TOP src add-ons translators tiff ; SubInclude HAIKU_TOP src add-ons translators wonderbrush ; Copied: haiku/trunk/src/add-ons/translators/tiff (from rev 23996, haiku/trunk/src/add-ons/translators/libtiff) Modified: haiku/trunk/src/add-ons/translators/tiff/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/libtiff/Jamfile 2008-02-18 08:57:35 UTC (rev 23996) +++ haiku/trunk/src/add-ons/translators/tiff/Jamfile 2008-02-18 09:04:48 UTC (rev 23998) @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src add-ons translators libtiff ; +SubDir HAIKU_TOP src add-ons translators tiff ; SetSubDirSupportedPlatformsBeOSCompatible ; From solaja at gmail.com Mon Feb 18 10:16:46 2008 From: solaja at gmail.com (Zenja Solaja) Date: Mon, 18 Feb 2008 20:16:46 +1100 Subject: [Haiku-commits] unsubscribe Message-ID: <474d25b90802180116j3c1625caoa8a1829d462969fb@mail.gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: From axeld at mail.berlios.de Mon Feb 18 13:28:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Feb 2008 13:28:32 +0100 Subject: [Haiku-commits] r23999 - haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart Message-ID: <200802181228.m1ICSVM5020453@sheep.berlios.de> Author: axeld Date: 2008-02-18 13:28:31 +0100 (Mon, 18 Feb 2008) New Revision: 23999 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23999&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp Log: Added a bit more debug output. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp 2008-02-18 09:04:48 UTC (rev 23998) +++ haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp 2008-02-18 12:28:31 UTC (rev 23999) @@ -243,6 +243,9 @@ agpStatus = fix_rate_support(agpStatus); } + TRACE("device %u.%u.%u has AGP capabilities %lx\n", deviceInfo.info.bus, + deviceInfo.info.device, deviceInfo.info.function, agpStatus); + // block non-supported AGP modes command &= (agpStatus & (AGP_3_MODE | AGP_RATE_MASK)) | ~(AGP_3_MODE | AGP_RATE_MASK); @@ -358,6 +361,8 @@ static void set_pci_mode() { + TRACE("set PCI mode on all AGP capable devices.\n"); + // First program all graphics cards for (uint32 index = 0; index < sDeviceCount; index++) { @@ -873,6 +878,7 @@ } command = fix_rate_command(command); + TRACE("set AGP command %lx on all capable devices.\n", command); // The order of programming differs for enabling/disabling AGP mode // (see AGP specification) From axeld at mail.berlios.de Mon Feb 18 13:31:17 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Feb 2008 13:31:17 +0100 Subject: [Haiku-commits] r24000 - haiku/trunk/src/system/kernel Message-ID: <200802181231.m1ICVHY0020992@sheep.berlios.de> Author: axeld Date: 2008-02-18 13:31:17 +0100 (Mon, 18 Feb 2008) New Revision: 24000 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24000&view=rev Modified: haiku/trunk/src/system/kernel/signal.cpp Log: * sigsuspend() must only block blockable signals. * Minor comment cleanup. Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-02-18 12:28:31 UTC (rev 23999) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-02-18 12:31:17 UTC (rev 24000) @@ -1,11 +1,11 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Copyright 2002, Angelo Mottola, a.mottola at libero.it. * * Distributed under the terms of the MIT License. */ -/* POSIX signals handling routines */ +/*! POSIX signals handling routines */ #include #include @@ -617,7 +617,8 @@ if (thread == NULL) thread = thread_get_current_thread(); - return atomic_get(&thread->sig_pending) & ~atomic_get(&thread->sig_block_mask); + return atomic_get(&thread->sig_pending) + & ~atomic_get(&thread->sig_block_mask); } @@ -654,12 +655,9 @@ } -/** \brief sigaction() for the specified thread. - * - * A \a threadID is < 0 specifies the current thread. - * - */ - +/*! \brief sigaction() for the specified thread. + A \a threadID is < 0 specifies the current thread. +*/ int sigaction_etc(thread_id threadID, int signal, const struct sigaction *act, struct sigaction *oldAction) @@ -721,8 +719,7 @@ } -/** Triggers a SIGALRM to the thread that issued the timer and reschedules */ - +/*! Triggers a SIGALRM to the thread that issued the timer and reschedules */ static int32 alarm_event(timer *t) { @@ -731,7 +728,8 @@ // set_alarm(). // Since thread->alarm is this timer structure, we can just // cast it back - ugly but it works for now - struct thread *thread = (struct thread *)((uint8 *)t - offsetof(struct thread, alarm)); + struct thread *thread = (struct thread *)((uint8 *)t + - offsetof(struct thread, alarm)); // ToDo: investigate adding one user parameter to the timer structure to fix this hack TRACE(("alarm_event: thread = %p\n", thread)); @@ -741,12 +739,11 @@ } -/** Sets the alarm timer for the current thread. The timer fires at the - * specified time in the future, periodically or just once, as determined - * by \a mode. - * \return the time left until a previous set alarm would have fired. - */ - +/*! Sets the alarm timer for the current thread. The timer fires at the + specified time in the future, periodically or just once, as determined + by \a mode. + \return the time left until a previous set alarm would have fired. +*/ bigtime_t set_alarm(bigtime_t time, uint32 mode) { @@ -774,10 +771,9 @@ } -/** Replace the current signal block mask and wait for any event to happen. - * Before returning, the original signal block mask is reinstantiated. - */ - +/*! Replace the current signal block mask and wait for any event to happen. + Before returning, the original signal block mask is reinstantiated. +*/ int sigsuspend(const sigset_t *mask) { @@ -787,7 +783,7 @@ // Set the new block mask and interuptably block wait for a condition // variable no one will ever notify. - atomic_set(&thread->sig_block_mask, *mask); + atomic_set(&thread->sig_block_mask, *mask & BLOCKABLE_SIGNALS); ConditionVariable conditionVar; conditionVar.Publish(mask, "sigsuspend"); From axeld at mail.berlios.de Mon Feb 18 13:33:07 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Feb 2008 13:33:07 +0100 Subject: [Haiku-commits] r24001 - haiku/trunk/src/tests/kits/net Message-ID: <200802181233.m1ICX7mw021136@sheep.berlios.de> Author: axeld Date: 2008-02-18 13:33:06 +0100 (Mon, 18 Feb 2008) New Revision: 24001 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24001&view=rev Modified: haiku/trunk/src/tests/kits/net/tcp_server.c Log: * Added keyword "full" that will try to send about 1 MB at once. Modified: haiku/trunk/src/tests/kits/net/tcp_server.c =================================================================== --- haiku/trunk/src/tests/kits/net/tcp_server.c 2008-02-18 12:31:17 UTC (rev 24000) +++ haiku/trunk/src/tests/kits/net/tcp_server.c 2008-02-18 12:33:06 UTC (rev 24001) @@ -18,7 +18,7 @@ #define MYPORT 1234 // the port users will be connecting to #define BACKLOG 10 // how many pending connections queue will hold -#define MAXDATASIZE 100 +#define MAXDATASIZE 1065537 static void @@ -95,11 +95,21 @@ if (!fork()) { while (1) { // child's child process - if (fgets(buf, MAXDATASIZE-1, stdin) == NULL) { + if (fgets(buf, MAXDATASIZE, stdin) == NULL) { perror("fgets"); exit(1); } + if (!strcmp(buf, "full\n")) { + int i; +puts("HY"); + for (i = 0; i < MAXDATASIZE - 2; i++) { + buf[i] = 'a' + (i % 26); + } + buf[MAXDATASIZE - 2] = '\n'; + buf[MAXDATASIZE - 1] = '\0'; + } + if (send(new_fd, buf, strlen(buf), 0) == -1) { perror("send"); exit(1); @@ -109,7 +119,7 @@ ssize_t numBytes; while (1) { // child process - if ((numBytes = recv(new_fd, buf, MAXDATASIZE-1, 0)) == -1) { + if ((numBytes = recv(new_fd, buf, MAXDATASIZE, 0)) == -1) { perror("recv"); exit(1); } From superstippi at gmx.de Mon Feb 18 13:39:17 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 18 Feb 2008 13:39:17 +0100 Subject: [Haiku-commits] r23977 - haiku/trunk/src/apps/mail In-Reply-To: <1013108252-BeMail@kirilla> References: <1013108252-BeMail@kirilla> Message-ID: <20080218133917.818.1@stippis2.1203337255.fake> Jonas Sundstr?m wrote (2008-02-17, 16:45:45 [+0100]): > "Fran?ois Revol" wrote: > > > Author: kirilla > > > Date: 2008-02-17 15:36:01 +0100 (Sun, 17 Feb 2008) New Revision: 23977 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23977&view=rev > > > > > > Modified: > > > haiku/trunk/src/apps/mail/MailWindow.cpp > > > Log: > > > 0L constant typo? Remove menu item before deleting it. > > > > No it's not a typo, it's a gccish which means Long, just like LL means > > long long, to avoid having to do a cast. > > A standard way of doing that would be using INT32_C(0), see > > http://linux.die.net/man/3/int32_c > > (not sure we have all of them, BeOS didn't have any) > > Sorry about that. Does it matter enough to put the 0L back? There was definitely a bug because I meant RemoveItem() instead of ItemAt(). You could change the code to do it all at once (like before, but replace ItemAt(0L) with RemoveItem(0L)). Thanks for the fix anyways! Best regards, -Stephan From axeld at mail.berlios.de Mon Feb 18 13:42:34 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Feb 2008 13:42:34 +0100 Subject: [Haiku-commits] r24002 - haiku/trunk/src/servers/syslog_daemon Message-ID: <200802181242.m1ICgY29022411@sheep.berlios.de> Author: axeld Date: 2008-02-18 13:42:34 +0100 (Mon, 18 Feb 2008) New Revision: 24002 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24002&view=rev Modified: haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp Log: Added "FTP" facility string. Modified: haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp =================================================================== --- haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp 2008-02-18 12:33:06 UTC (rev 24001) +++ haiku/trunk/src/servers/syslog_daemon/syslog_output.cpp 2008-02-18 12:42:34 UTC (rev 24002) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -21,8 +21,8 @@ static const char *kFacilities[] = { "KERN", "USER", "MAIL", "DAEMON", "AUTH", "SYSLOGD", "LPR", "NEWS", - "UUCP", "CRON", "AUTHPRIV", - "", "", "", "", "", + "UUCP", "CRON", "AUTHPRIV", "FTP", + "", "", "", "", "LOCAL0", "LOCAL1", "LOCAL2", "LOCAL3", "LOCAL4", "LOCAL5", "LOCAL6", "LOCAL7", NULL From jackburton at mail.berlios.de Mon Feb 18 14:04:52 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 14:04:52 +0100 Subject: [Haiku-commits] r24003 - haiku/trunk/src/kits/interface Message-ID: <200802181304.m1ID4qaa024884@sheep.berlios.de> Author: jackburton Date: 2008-02-18 14:04:52 +0100 (Mon, 18 Feb 2008) New Revision: 24003 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24003&view=rev Modified: haiku/trunk/src/kits/interface/MenuField.cpp Log: pass -1 as first parameter of StartMenuBar(), otherwise it will hide the cursor (used for keyboard navigation). Fixes bug #1807 Modified: haiku/trunk/src/kits/interface/MenuField.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuField.cpp 2008-02-18 12:42:34 UTC (rev 24002) +++ haiku/trunk/src/kits/interface/MenuField.cpp 2008-02-18 13:04:52 UTC (rev 24003) @@ -301,9 +301,10 @@ BRect bounds = fMenuBar->ConvertFromParent(Bounds()); - fMenuBar->StartMenuBar(0, false, true, &bounds); + fMenuBar->StartMenuBar(-1, false, true, &bounds); - fMenuTaskID = spawn_thread((thread_func)_thread_entry, "_m_task_", B_NORMAL_PRIORITY, this); + fMenuTaskID = spawn_thread((thread_func)_thread_entry, + "_m_task_", B_NORMAL_PRIORITY, this); if (fMenuTaskID >= 0) resume_thread(fMenuTaskID); } From jackburton at mail.berlios.de Mon Feb 18 14:21:02 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 14:21:02 +0100 Subject: [Haiku-commits] r24004 - haiku/trunk/src/kits/interface Message-ID: <200802181321.m1IDL2dw026642@sheep.berlios.de> Author: jackburton Date: 2008-02-18 14:21:02 +0100 (Mon, 18 Feb 2008) New Revision: 24004 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24004&view=rev Modified: haiku/trunk/src/kits/interface/MenuBar.cpp Log: Patch by Denis Washington: menubars now, like menus, can be navigated without keeping the mouse button pressed. Modified: haiku/trunk/src/kits/interface/MenuBar.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuBar.cpp 2008-02-18 13:04:52 UTC (rev 24003) +++ haiku/trunk/src/kits/interface/MenuBar.cpp 2008-02-18 13:21:02 UTC (rev 24004) @@ -477,7 +477,7 @@ // - nonsticky mode and different selection, // - clicked in sticky mode if (fSelected == NULL - || (!_IsStickyMode() && menuItem != fSelected) + || (menuItem != fSelected) || (buttons != 0 && _IsStickyMode())) { if (menuItem->Submenu() != NULL) { if (menuItem->Submenu()->Window() == NULL) { From jackburton at mail.berlios.de Mon Feb 18 14:24:14 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 14:24:14 +0100 Subject: [Haiku-commits] r24005 - haiku/trunk/src/kits/interface Message-ID: <200802181324.m1IDOE4q026978@sheep.berlios.de> Author: jackburton Date: 2008-02-18 14:24:13 +0100 (Mon, 18 Feb 2008) New Revision: 24005 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24005&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: reverted r21961. A menu could be closed, if the user clicked (with the menu opened) on a view which uses GetMouse() in a loop (PE, tracker), since it stealed the mousedown message. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-02-18 13:21:02 UTC (rev 24004) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-02-18 13:24:13 UTC (rev 24005) @@ -1058,10 +1058,10 @@ { BView *view = dynamic_cast(target); - // Close an eventually opened menu, if this click targets the - // preferred handler, and unless the target is the menu itself + // Close an eventually opened menu + // unless the target is the menu itself BMenu *menu = dynamic_cast(fFocus); - if (menu != NULL && menu != view && PreferredHandler() == target + if (menu != NULL && menu != view && menu->State() != MENU_STATE_CLOSED) { menu->QuitTracking(); return; From jackburton at mail.berlios.de Mon Feb 18 15:30:50 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 18 Feb 2008 15:30:50 +0100 Subject: [Haiku-commits] r24006 - haiku/trunk/src/kits/interface Message-ID: <200802181430.m1IEUoPe006099@sheep.berlios.de> Author: jackburton Date: 2008-02-18 15:30:49 +0100 (Mon, 18 Feb 2008) New Revision: 24006 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24006&view=rev Modified: haiku/trunk/src/kits/interface/MenuBar.cpp Log: fixed a few problems in BMenuBar, triggered by the particular use the Menu preflet makes of it. Modified: haiku/trunk/src/kits/interface/MenuBar.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuBar.cpp 2008-02-18 13:24:13 UTC (rev 24005) +++ haiku/trunk/src/kits/interface/MenuBar.cpp 2008-02-18 14:30:49 UTC (rev 24006) @@ -464,7 +464,7 @@ GetMouse(&where, &buttons); window->Unlock(); } - + while (fState != MENU_STATE_CLOSED) { bigtime_t snoozeAmount = 40000; if (Window() == NULL || !window->Lock()) @@ -472,29 +472,19 @@ BMenuItem *menuItem = _HitTestItems(where, B_ORIGIN); if (menuItem != NULL) { - // Select item if: - // - no previous selection - // - nonsticky mode and different selection, - // - clicked in sticky mode - if (fSelected == NULL - || (menuItem != fSelected) - || (buttons != 0 && _IsStickyMode())) { - if (menuItem->Submenu() != NULL) { - if (menuItem->Submenu()->Window() == NULL) { - // open the menu if it's not opened yet - _SelectItem(menuItem); - if (_IsStickyMode()) - _SetStickyMode(false); - } else { - // Menu was already opened, close it and bail - _SelectItem(NULL); - fState = MENU_STATE_CLOSED; - fChosenItem = NULL; - } + if (menuItem->Submenu() != NULL && menuItem != fSelected) { + if (menuItem->Submenu()->Window() == NULL) { + // open the menu if it's not opened yet + _SelectItem(menuItem); } else { - // No submenu, just select the item - _SelectItem(menuItem); + // Menu was already opened, close it and bail + _SelectItem(NULL); + fState = MENU_STATE_CLOSED; + fChosenItem = NULL; } + } else { + // No submenu, just select the item + _SelectItem(menuItem); } } else if (_OverSubmenu(fSelected, ConvertToScreen(where))) { // call _Track() from the selected sub-menu when the mouse cursor @@ -550,9 +540,12 @@ window->Unlock(); } - if ((buttons != 0 && _IsStickyMode() && menuItem == NULL)) - fState = MENU_STATE_CLOSED; - else if (buttons == 0 && !_IsStickyMode()) { + if (buttons != 0 && _IsStickyMode()) { + if (menuItem == NULL) + fState = MENU_STATE_CLOSED; + else + _SetStickyMode(false); + } else if (buttons == 0 && !_IsStickyMode()) { if ((fSelected != NULL && fSelected->Submenu() == NULL) || menuItem == NULL) { fChosenItem = fSelected; @@ -562,7 +555,7 @@ } } } - + if (window->Lock()) { if (fSelected != NULL) _SelectItem(NULL); @@ -582,6 +575,7 @@ *action = fState; return fChosenItem; + } From axeld at mail.berlios.de Mon Feb 18 19:04:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Feb 2008 19:04:32 +0100 Subject: [Haiku-commits] r24007 - in haiku/trunk/src/tests/add-ons/kernel/drivers: . audio Message-ID: <200802181804.m1II4WAP009093@sheep.berlios.de> Author: axeld Date: 2008-02-18 19:04:30 +0100 (Mon, 18 Feb 2008) New Revision: 24007 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24007&view=rev Added: haiku/trunk/src/tests/add-ons/kernel/drivers/audio/ haiku/trunk/src/tests/add-ons/kernel/drivers/audio/Jamfile haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile Log: * Wrote a multi audio test application to debug the HD-Audio driver. * Right now, it even plays something, but it doesn't sound like it should (more like noise). * Also, the hda driver only works once, unlike the auich driver. Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile 2008-02-18 14:30:49 UTC (rev 24006) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/Jamfile 2008-02-18 18:04:30 UTC (rev 24007) @@ -1,4 +1,5 @@ SubDir HAIKU_TOP src tests add-ons kernel drivers ; +SubInclude HAIKU_TOP src tests add-ons kernel drivers audio ; SubInclude HAIKU_TOP src tests add-ons kernel drivers random ; SubInclude HAIKU_TOP src tests add-ons kernel drivers tty ; Added: haiku/trunk/src/tests/add-ons/kernel/drivers/audio/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/audio/Jamfile 2008-02-18 14:30:49 UTC (rev 24006) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/audio/Jamfile 2008-02-18 18:04:30 UTC (rev 24007) @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src tests add-ons kernel drivers audio ; + +SubDirHdrs [ FDirName $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell ] ; +UsePrivateHeaders [ FDirName media ] ; + +SubDirCcFlags [ FDefines HAIKU_MULTI_AUDIO=1 ] ; + +SimpleTest multi_audio_test : + multi_audio_test.cpp + argv.c + + : libroot.so +; + +SEARCH on [ FGristFiles + argv.c + ] = [ FDirName $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell ] ; Added: haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp 2008-02-18 14:30:49 UTC (rev 24006) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp 2008-02-18 18:04:30 UTC (rev 24007) @@ -0,0 +1,497 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include +#include +#include + +#ifdef HAIKU_MULTI_AUDIO +# include +#else +# include +#endif + +#include "argv.h" + + +#define MAX_CONTROLS 128 +#define MAX_CHANNELS 32 +#define NUM_BUFFERS 16 + +const uint32 kSampleRates[] = { + 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, + 48000, 64000, 88200, 96000, 176400, 192000, 384000, 1536000 +}; +const struct { + uint32 type; + char* name; +} kFormats[] = { + {B_FMT_8BIT_S, "8bit"}, + {B_FMT_8BIT_U, "8bit-unsigned"}, + {B_FMT_16BIT, "16bit"}, + {B_FMT_18BIT, "18bit"}, + {B_FMT_20BIT, "20bit"}, + {B_FMT_24BIT, "24bit"}, + {B_FMT_32BIT, "32bit"}, + {B_FMT_FLOAT, "float"}, + {B_FMT_DOUBLE, "double"} +}; + + +struct cmd_entry { + char* name; + void (*func)(int argc, char **argv); + char* help; +}; + + +extern const char* __progname; + +static void do_help(int argc, char** argv); + + +static int sDevice; +static multi_channel_info sChannelInfo[MAX_CHANNELS]; +static multi_description sDescription; +static uint32 sRate = B_SR_48000; +static uint32 sFormat = B_FMT_32BIT;//B_FMT_FLOAT;//B_FMT_16BIT; +static uint32 sEnabledChannels = ~0; + + +static uint32 +channel_count() +{ + return sDescription.output_channel_count + sDescription.input_channel_count; +} + + +static void +set_frame(char* frame, uint32 format, float value) +{ + switch (format) { + case B_FMT_16BIT: + *(int16*)frame = int16(value * INT16_MAX); + break; + case B_FMT_32BIT: + *(int32*)frame = int32(value * INT32_MAX); + break; + default: + *(float*)frame = value; + break; + } +} + + +static uint32 +get_rate(uint32 rateBits) +{ + uint32 rate = 0; + for (uint32 i = 0; (1UL << i) <= rateBits; i++) { + if ((1UL << i) == rateBits) + rate = kSampleRates[i]; + } + + return rate; +} + + +static const char* +get_format_name(uint32 format) +{ + for (uint32 i = 0; i < sizeof(kFormats) / sizeof(kFormats[0]); i++) { + if (kFormats[i].type == format) + return kFormats[i].name; + } + + return "unknown"; +} + + +static const char* +get_kind_name(uint32 kind) +{ + switch (kind) { + case B_MULTI_OUTPUT_CHANNEL: + return "out"; + case B_MULTI_INPUT_CHANNEL: + return "in"; + case B_MULTI_OUTPUT_BUS: + return "bus-out"; + case B_MULTI_INPUT_BUS: + return "bus-in"; + case B_MULTI_AUX_BUS: + return "bus-aux"; + + default: + return "unknown"; + } +} + + +// #pragma mark - Commands + + +static void +do_rate(int argc, char** argv) +{ + if (argc > 1) { + uint32 rate = strtoul(argv[1], NULL, 0); + uint32 bits = 0; + + for (uint32 i = 0; i < sizeof(kSampleRates) / sizeof(kSampleRates[0]); + i++) { + if (rate == kSampleRates[i]) + bits = 1 << i; + } + + if (bits == 0) { + fprintf(stderr, "Invalid sample rate %ld!\n", rate); + printf("Valid values are:"); + for (uint32 i = 0; + i < sizeof(kSampleRates) / sizeof(kSampleRates[0]); i++) { + printf(" %lu", kSampleRates[i]); + } + putchar('\n'); + return; + } + sRate = bits; + } + + printf("Current sample rate is %lu Hz (0x%lx)\n", get_rate(sRate), sRate); +} + + +static void +do_format(int argc, char** argv) +{ + printf("Current sample format is %s (0x%lx)\n", get_format_name(sFormat), + sFormat); +} + + +static void +do_desc(int argc, char** argv) +{ + printf("friendly name:\t\t\t%s\n", sDescription.friendly_name); + printf("vendor:\t\t\t\t%s\n\n", sDescription.vendor_info); + + printf("output rates:\t\t\t0x%lx (max %lu)\n", sDescription.output_rates, + get_rate(sDescription.output_rates)); + printf("input rates:\t\t\t0x%lx (max %lu)\n", sDescription.input_rates, + get_rate(sDescription.input_rates)); + printf("max cont. var. sample rate:\t%.0f\n", + sDescription.max_cvsr_rate); + printf("min cont. var. sample rate:\t%.0f\n", + sDescription.min_cvsr_rate); + printf("output formats:\t\t\t0x%lx\n", sDescription.output_formats); + printf("input formats:\t\t\t0x%lx\n", sDescription.input_formats); + printf("lock sources:\t\t\t0x%lx\n", sDescription.lock_sources); + printf("timecode sources:\t\t0x%lx\n", sDescription.timecode_sources); + printf("interface flags:\t\t0x%lx\n", sDescription.interface_flags); + printf("control panel string:\t\t\t%s\n", sDescription.control_panel); + + printf("\nchannels:\n"); + printf(" %ld outputs, %ld inputs\n", sDescription.output_channel_count, + sDescription.input_channel_count); + printf(" %ld out busses, %ld in busses\n", + sDescription.output_bus_channel_count, + sDescription.input_bus_channel_count); + printf("\n ID\tkind\t designations\tconnectors\n"); + + for (uint32 i = 0 ; i < channel_count(); i++) { + printf("%4ld\t%-10s 0x%lx\t0x%lx\n", sDescription.channels[i].channel_id, + get_kind_name(sDescription.channels[i].kind), + sDescription.channels[i].designations, + sDescription.channels[i].connectors); + } +} + + +static void +do_channels(int argc, char** argv) +{ + uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; + + printf("%ld channels:\n ", channel_count()); + for (uint32 i = 0; i < channel_count(); i++) { + printf(enabled & 1 ? "x" : "-"); + enabled >>= 1; + } + putchar('\n'); + +/* + sEnabledChannels = enabled; + + multi_channel_enable channelEnable; + uint32 enabled; + + channelEnable.info_size = sizeof(multi_channel_enable); + channelEnable.enable_bits = (uchar*)&enabled; + + if (ioctl(sDevice, B_MULTI_GET_ENABLED_CHANNELS, &channelEnable, + sizeof(channelEnable)) < B_OK) { + fprintf(stderr, "Failed on B_MULTI_GET_ENABLED_CHANNELS: %s\n", + strerror(errno)); + return; + } + + + multi_channel_enable channelEnable; + uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; + + channelEnable.lock_source = B_MULTI_LOCK_INTERNAL; + if (ioctl(sDevice, B_MULTI_SET_ENABLED_CHANNELS, &channelEnable, + sizeof(multi_channel_enable)) < B_OK) { + fprintf(stderr, "Setting enabled channels failed: %s\n", + strerror(errno)); + } +*/ +} + + +static void +do_play(int argc, char** argv) +{ + multi_channel_enable channelEnable; + uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; + + channelEnable.enable_bits = (uchar*)&enabled; + channelEnable.lock_source = B_MULTI_LOCK_INTERNAL; + if (ioctl(sDevice, B_MULTI_SET_ENABLED_CHANNELS, &channelEnable, + sizeof(multi_channel_enable)) < B_OK) { + fprintf(stderr, "Setting enabled channels failed: %s\n", + strerror(errno)); + } + + multi_format_info formatInfo; + formatInfo.info_size = sizeof(multi_format_info); + formatInfo.output.rate = sRate; + formatInfo.output.cvsr = 0; + formatInfo.output.format = sFormat; + formatInfo.input.rate = formatInfo.output.rate; + formatInfo.input.cvsr = formatInfo.output.cvsr; + formatInfo.input.format = formatInfo.output.format; + + if (ioctl(sDevice, B_MULTI_SET_GLOBAL_FORMAT, &formatInfo, + sizeof(multi_format_info)) < B_OK) { + printf("Setting global format failed: %s\n", strerror(errno)); + } + + if (ioctl(sDevice, B_MULTI_GET_GLOBAL_FORMAT, &formatInfo, + sizeof(multi_format_info)) < B_OK) { + printf("Getting global format failed: %s\n", strerror(errno)); + } + + printf("format %s (0x%lx)\n", get_format_name(formatInfo.output.format), + formatInfo.output.format); + printf("sample rate %lu (0x%lx)\n", get_rate(formatInfo.output.rate), + formatInfo.output.rate); + + buffer_desc playBuffers[NUM_BUFFERS * MAX_CHANNELS]; + buffer_desc recordBuffers[NUM_BUFFERS * MAX_CHANNELS]; + buffer_desc* playBufferDesc[NUM_BUFFERS]; + buffer_desc* recordBufferDesc[NUM_BUFFERS]; + + for (uint32 i = 0; i < NUM_BUFFERS; i++) { + playBufferDesc[i] = &playBuffers[i * MAX_CHANNELS]; + recordBufferDesc[i] = &recordBuffers[i * MAX_CHANNELS]; + } + + multi_buffer_list bufferList; + bufferList.info_size = sizeof(multi_buffer_list); + bufferList.request_playback_buffer_size = 0; + bufferList.request_playback_buffers = NUM_BUFFERS; + bufferList.request_playback_channels = sDescription.output_channel_count; + bufferList.playback_buffers = (buffer_desc**)playBufferDesc; + bufferList.request_record_buffer_size = 0; + bufferList.request_record_buffers = NUM_BUFFERS; + bufferList.request_record_channels = sDescription.input_channel_count; + bufferList.record_buffers = (buffer_desc**)recordBufferDesc; + + if (ioctl(sDevice, B_MULTI_GET_BUFFERS, &bufferList, + sizeof(multi_buffer_list)) < B_OK) { + printf("Getting buffers failed: %s\n", strerror(errno)); + return; + } + + printf("playback: buffer count %ld, channels %ld, buffer size %ld\n", + bufferList.return_playback_buffers, bufferList.return_playback_channels, + bufferList.return_playback_buffer_size); + printf("record: buffer count %ld, channels %ld, buffer size %ld\n", + bufferList.return_record_buffers, bufferList.return_record_channels, + bufferList.return_record_buffer_size); + + // fill buffers with data + + for (int32 i = 0; i < bufferList.return_playback_buffers; i++) { + size_t stride = bufferList.playback_buffers[i][0].stride; + for (int32 channel = 0; channel < sDescription.output_channel_count; + channel++) { + char* dest = bufferList.playback_buffers[i][channel].base; + for (uint32 frame = 0; + frame < bufferList.return_playback_buffer_size; frame++) { + set_frame(dest, formatInfo.output.format, sin(frame / 1000.0)); + dest += stride; + } + } + } + + multi_buffer_info bufferInfo; + memset(&bufferInfo, 0, sizeof(multi_buffer_info)); + bufferInfo.info_size = sizeof(multi_buffer_info); + + bigtime_t startTime = system_time(); + while (true) { + if (system_time() - startTime > 1000000LL) + break; + + if (ioctl(sDevice, B_MULTI_BUFFER_EXCHANGE, &bufferInfo, + sizeof(multi_buffer_list)) < B_OK) { + printf("Getting buffers failed: %s\n", strerror(errno)); + } + + bufferInfo.playback_buffer_cycle = (bufferInfo.playback_buffer_cycle + 1) + % bufferList.request_playback_buffers; + } + + // clear buffers + + for (int32 i = 0; i < bufferList.return_playback_buffers; i++) { + size_t stride = bufferList.playback_buffers[i][0].stride; + for (int32 channel = 0; channel < sDescription.output_channel_count; + channel++) { + char* dest = bufferList.playback_buffers[i][channel].base; + for (uint32 frame = bufferList.return_playback_buffer_size; + frame-- > 0; ) { + set_frame(dest, formatInfo.output.format, 0); + dest += stride; + } + } + } + + if (ioctl(sDevice, B_MULTI_BUFFER_FORCE_STOP, NULL, 0) < B_OK) { + printf("Stopping audio failed: %s\n", strerror(errno)); + } +} + + +static cmd_entry sBuiltinCommands[] = { + {"rate", do_rate, "Set sample rate"}, + {"format", do_format, "Set sample format"}, + {"desc", do_desc, "Shows description"}, + {"channels", do_channels, "Shows enabled/disabled channels"}, + {"play", do_play, "Plays a tone"}, + {"help", do_help, "prints this help text"}, + {"quit", NULL, "exits the application"}, + {NULL, NULL, NULL}, +}; + + +static void +do_help(int argc, char** argv) +{ + printf("Available commands:\n"); + + for (cmd_entry* command = sBuiltinCommands; command->name != NULL; command++) { + printf("%8s - %s\n", command->name, command->help); + } +} + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", __progname); + return 1; + } + + // open driver + + sDevice = open(argv[1], O_RDWR); + if (sDevice < 0) { + fprintf(stderr, "%s: Could not open \"%s\": %s\n", __progname, argv[1], + strerror(errno)); + return 1; + } + + // get description + + memset(&sDescription, 0, sizeof(multi_description)); + sDescription.info_size = sizeof(multi_description); + sDescription.request_channel_count = MAX_CHANNELS; + sDescription.channels = sChannelInfo; + + if (ioctl(sDevice, B_MULTI_GET_DESCRIPTION, &sDescription, + sizeof(multi_description)) < 0) { + fprintf(stderr, "%s: Getting description failed: %s\n", __progname, + strerror(errno)); + close(sDevice); + return 1; + } + + // get enabled channels + + multi_channel_enable channelEnable; + uint32 enabled; + + channelEnable.info_size = sizeof(multi_channel_enable); + channelEnable.enable_bits = (uchar*)&enabled; + + if (ioctl(sDevice, B_MULTI_GET_ENABLED_CHANNELS, &channelEnable, + sizeof(channelEnable)) < B_OK) { + fprintf(stderr, "Failed on B_MULTI_GET_ENABLED_CHANNELS: %s\n", + strerror(errno)); + return 1; + } + + sEnabledChannels = enabled; + + while (true) { + printf("> "); + fflush(stdout); + + char line[1024]; + if (fgets(line, sizeof(line), stdin) == NULL) + break; + + argc = 0; + argv = build_argv(line, &argc); + if (argv == NULL || argc == 0) + continue; + + int length = strlen(argv[0]); + + if (!strcmp(argv[0], "quit") + || !strcmp(argv[0], "exit") + || !strcmp(argv[0], "q")) + break; + + bool found = false; + + for (cmd_entry* command = sBuiltinCommands; command->name != NULL; command++) { + if (!strncmp(command->name, argv[0], length)) { + command->func(argc, argv); + found = true; + break; + } + } + + if (!found) + fprintf(stderr, "Unknown command \"%s\". Type \"help\" for a list of commands.\n", argv[0]); + + free(argv); + } + + close(sDevice); + return 0; +} + From aldeck at mail.berlios.de Mon Feb 18 19:08:49 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Mon, 18 Feb 2008 19:08:49 +0100 Subject: [Haiku-commits] r24008 - haiku/trunk/src/kits/tracker Message-ID: <200802181808.m1II8nDT014410@sheep.berlios.de> Author: aldeck Date: 2008-02-18 19:08:48 +0100 (Mon, 18 Feb 2008) New Revision: 24008 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24008&view=rev Modified: haiku/trunk/src/kits/tracker/SettingsViews.cpp haiku/trunk/src/kits/tracker/TrackerSettings.cpp haiku/trunk/src/kits/tracker/TrackerSettingsWindow.cpp haiku/trunk/src/kits/tracker/TrackerSettingsWindow.h Log: - Revert button's first update didn't work since revert data is stored in the Show() method. - Default data is defined in two places, and was inconsistent. - Color comparisons could be done with the wrong alpha. note: BColorControl's behavior wrt alpha might differ from R5's. This fixes part of #254 Modified: haiku/trunk/src/kits/tracker/SettingsViews.cpp =================================================================== --- haiku/trunk/src/kits/tracker/SettingsViews.cpp 2008-02-18 18:04:30 UTC (rev 24007) +++ haiku/trunk/src/kits/tracker/SettingsViews.cpp 2008-02-18 18:08:48 UTC (rev 24008) @@ -53,7 +53,15 @@ static const float kItemExtraSpacing = 2.0f; static const float kIndentSpacing = 12.0f; +//TODO: defaults should be set in one place only (TrackerSettings.cpp) while +// being accessible from here. +// What about adding DefaultValue(), IsDefault() etc... methods to xxxValueSetting ? +static const uint8 kSpaceBarAlpha = 192; +static const rgb_color kDefaultUsedSpaceColor = {0, 203, 0, kSpaceBarAlpha}; +static const rgb_color kDefaultFreeSpaceColor = {255, 255, 255, kSpaceBarAlpha}; +static const rgb_color kDefaultWarningSpaceColor = {203, 0, 0, kSpaceBarAlpha}; + static void send_bool_notices(uint32 what, const char *name, bool value) { @@ -1145,15 +1153,19 @@ case kSpaceBarColorChanged: { + rgb_color color = fColorControl->ValueAsColor(); + color.alpha = kSpaceBarAlpha; + //alpha is ignored by BColorControl but is checked in equalities + switch (fCurrentColor) { case 0: - settings.SetUsedSpaceColor(fColorControl->ValueAsColor()); + settings.SetUsedSpaceColor(color); break; case 1: - settings.SetFreeSpaceColor(fColorControl->ValueAsColor()); + settings.SetFreeSpaceColor(color); break; case 2: - settings.SetWarningSpaceColor(fColorControl->ValueAsColor()); + settings.SetWarningSpaceColor(color); break; } @@ -1183,12 +1195,12 @@ send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false); } - if (settings.UsedSpaceColor() != Color(0, 203, 0, 192) - || settings.FreeSpaceColor() != Color(255, 255, 255, 192) - || settings.WarningSpaceColor() != Color(203, 0, 0, 192)) { - settings.SetUsedSpaceColor(Color(0, 203, 0, 192)); - settings.SetFreeSpaceColor(Color(255, 255, 255, 192)); - settings.SetWarningSpaceColor(Color(203, 0, 0, 192)); + if (settings.UsedSpaceColor() != kDefaultUsedSpaceColor + || settings.FreeSpaceColor() != kDefaultFreeSpaceColor + || settings.WarningSpaceColor() != kDefaultWarningSpaceColor) { + settings.SetUsedSpaceColor(kDefaultUsedSpaceColor); + settings.SetFreeSpaceColor(kDefaultFreeSpaceColor); + settings.SetWarningSpaceColor(kDefaultWarningSpaceColor); tracker->SendNotices(kSpaceBarColorChanged); } @@ -1202,9 +1214,9 @@ TrackerSettings settings; return settings.ShowVolumeSpaceBar() != false - || settings.UsedSpaceColor() != Color(0, 203, 0, 192) - || settings.FreeSpaceColor() != Color(255, 255, 255, 192) - || settings.WarningSpaceColor() != Color(203, 0, 0, 192); + || settings.UsedSpaceColor() != kDefaultUsedSpaceColor + || settings.FreeSpaceColor() != kDefaultFreeSpaceColor + || settings.WarningSpaceColor() != kDefaultWarningSpaceColor; } @@ -1273,7 +1285,7 @@ { TrackerSettings settings; - return fSpaceBarShow != (fSpaceBarShowCheckBox->Value() == B_CONTROL_ON) + return fSpaceBarShow != settings.ShowVolumeSpaceBar() || fUsedSpaceColor != settings.UsedSpaceColor() || fFreeSpaceColor != settings.FreeSpaceColor() || fWarningSpaceColor != settings.WarningSpaceColor(); Modified: haiku/trunk/src/kits/tracker/TrackerSettings.cpp =================================================================== --- haiku/trunk/src/kits/tracker/TrackerSettings.cpp 2008-02-18 18:04:30 UTC (rev 24007) +++ haiku/trunk/src/kits/tracker/TrackerSettings.cpp 2008-02-18 18:08:48 UTC (rev 24008) @@ -107,19 +107,12 @@ color.green = static_cast((value >> 8L) & 0xff); color.blue = static_cast(value & 0xff); - // zero alpha is invalid - if (color.alpha == 0) - color.alpha = 192; - return color; } + int32 ColorToValue(rgb_color color) { - // zero alpha is invalid - if (color.alpha == 0) - color.alpha = 192; - return color.alpha << 24L | color.red << 16L | color.green << 8L @@ -174,7 +167,7 @@ Add(fMountSharedVolumesOntoDesktop = new BooleanValueSetting("MountSharedVolumesOntoDesktop", true)); Add(fIntegrateNonBootBeOSDesktops = new BooleanValueSetting - ("IntegrateNonBootBeOSDesktops", true)); + ("IntegrateNonBootBeOSDesktops", false)); Add(fIntegrateAllNonBootDesktops = new BooleanValueSetting ("IntegrateAllNonBootDesktops", false)); Add(fEjectWhenUnmounting = new BooleanValueSetting("EjectWhenUnmounting", true)); @@ -343,8 +336,6 @@ void TrackerSettings::SetUsedSpaceColor(rgb_color color) { - if (color.alpha == 0) - color.alpha = 192; gTrackerState.fUsedSpaceColor->ValueChanged(ColorToValue(color)); } @@ -359,8 +350,6 @@ void TrackerSettings::SetFreeSpaceColor(rgb_color color) { - if (color.alpha == 0) - color.alpha = 192; gTrackerState.fFreeSpaceColor->ValueChanged(ColorToValue(color)); } @@ -375,8 +364,6 @@ void TrackerSettings::SetWarningSpaceColor(rgb_color color) { - if (color.alpha == 0) - color.alpha = 192; gTrackerState.fWarningSpaceColor->ValueChanged(ColorToValue(color)); } Modified: haiku/trunk/src/kits/tracker/TrackerSettingsWindow.cpp =================================================================== --- haiku/trunk/src/kits/tracker/TrackerSettingsWindow.cpp 2008-02-18 18:04:30 UTC (rev 24007) +++ haiku/trunk/src/kits/tracker/TrackerSettingsWindow.cpp 2008-02-18 18:08:48 UTC (rev 24008) @@ -203,6 +203,8 @@ fSettingsTypeListView->Invalidate(); + _UpdateButtons(); + Unlock(); } _inherited::Show(); @@ -239,6 +241,16 @@ void TrackerSettingsWindow::_HandleChangedContents() { + fSettingsTypeListView->Invalidate(); + _UpdateButtons(); + + TrackerSettings().SaveSettings(false); +} + + +void +TrackerSettingsWindow::_UpdateButtons() +{ int32 itemCount = fSettingsTypeListView->CountItems(); bool defaultable = false; @@ -248,12 +260,9 @@ defaultable |= _ViewAt(i)->IsDefaultable(); revertable |= _ViewAt(i)->IsRevertable(); } - - fSettingsTypeListView->Invalidate(); + fDefaultsButton->SetEnabled(defaultable); fRevertButton->SetEnabled(revertable); - - TrackerSettings().SaveSettings(false); } Modified: haiku/trunk/src/kits/tracker/TrackerSettingsWindow.h =================================================================== --- haiku/trunk/src/kits/tracker/TrackerSettingsWindow.h 2008-02-18 18:04:30 UTC (rev 24007) +++ haiku/trunk/src/kits/tracker/TrackerSettingsWindow.h 2008-02-18 18:08:48 UTC (rev 24008) @@ -63,6 +63,7 @@ void _HandlePressedDefaultsButton(); void _HandlePressedRevertButton(); void _HandleChangedSettingsView(); + void _UpdateButtons(); BListView *fSettingsTypeListView; BBox *fSettingsContainerBox; From jonas at kirilla.com Mon Feb 18 18:29:25 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Mon, 18 Feb 2008 18:29:25 +0100 CET Subject: [Haiku-commits] r23977 - haiku/trunk/src/apps/mail In-Reply-To: <20080218133917.818.1@stippis2.1203337255.fake> Message-ID: <1267131166-BeMail@kirilla> Stephan Assmus wrote: ... > There was definitely a bug because I meant RemoveItem() > instead of ItemAt(). You could change the code to do it all > at once (like before, but replace ItemAt(0L) with > RemoveItem(0L)). Thanks for the fix anyways! But it would have been against the style guide. ;)) " Avoid using assignments in while loops, don't use: BMenuItem *item; int32 index = 0; while ((item = ItemAt(index++)) != NULL) { ... " /Jonas. From jonas at kirilla.com Mon Feb 18 20:09:32 2008 From: jonas at kirilla.com (Jonas =?iso-8859-1?q?Sundstr=F6m?=) Date: Mon, 18 Feb 2008 20:09:32 +0100 CET Subject: [Haiku-commits] r24006 - haiku/trunk/src/kits/interface Message-ID: <1234440206-BeMail@kirilla> Did this change break toggling the menus? (Click to open, and then - if you so desire - just click again to close it.) I'm not sure I like the new behavior in Deskbar. With Deskbar in the top-right corner, moving the pointer from an application's entry to its Close All is likely to pass the application entry below it and replace the menu you were moving towards. /Jonas. From stefano.ceccherini at gmail.com Mon Feb 18 21:28:24 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 18 Feb 2008 21:28:24 +0100 Subject: [Haiku-commits] r24006 - haiku/trunk/src/kits/interface In-Reply-To: <1234440206-BeMail@kirilla> References: <1234440206-BeMail@kirilla> Message-ID: <894b9700802181228q77f3c8e2t9f09cc24c25e8c23@mail.gmail.com> 2008/2/18, Jonas Sundstr?m : > Did this change break toggling the menus? > (Click to open, and then - if you so desire - > just click again to close it.) Could be. > I'm not sure I like the new behavior in Deskbar. > With Deskbar in the top-right corner, moving the > pointer from an application's entry to its Close All > is likely to pass the application entry below it and > replace the menu you were moving towards. I'm a bit dubious too. Let's see if we can get used. From bonefish at mail.berlios.de Mon Feb 18 22:51:34 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 18 Feb 2008 22:51:34 +0100 Subject: [Haiku-commits] r24009 - haiku/trunk/src/system/kernel Message-ID: <200802182151.m1ILpYKI010936@sheep.berlios.de> Author: bonefish Date: 2008-02-18 22:51:34 +0100 (Mon, 18 Feb 2008) New Revision: 24009 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24009&view=rev Modified: haiku/trunk/src/system/kernel/signal.cpp Log: We forgot to unpublish our temporary condition variable. Since it was allocated on the stack, condition variable related structures would be trashed, causing all kinds of problems. Fixes #1811 and #1812. Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-02-18 18:08:48 UTC (rev 24008) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-02-18 21:51:34 UTC (rev 24009) @@ -796,6 +796,8 @@ break; } + conditionVar.Unpublish(); + // restore the original block mask atomic_set(&thread->sig_block_mask, oldMask); From mmlr at mail.berlios.de Mon Feb 18 23:54:13 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 18 Feb 2008 23:54:13 +0100 Subject: [Haiku-commits] r24010 - haiku/trunk/src/system/kernel Message-ID: <200802182254.m1IMsDi7018326@sheep.berlios.de> Author: mmlr Date: 2008-02-18 23:54:12 +0100 (Mon, 18 Feb 2008) New Revision: 24010 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24010&view=rev Modified: haiku/trunk/src/system/kernel/elf.cpp Log: We should lock around register_elf_image() as we modify the image hash in there. Modified: haiku/trunk/src/system/kernel/elf.cpp =================================================================== --- haiku/trunk/src/system/kernel/elf.cpp 2008-02-18 21:51:34 UTC (rev 24009) +++ haiku/trunk/src/system/kernel/elf.cpp 2008-02-18 22:54:12 UTC (rev 24010) @@ -1668,7 +1668,9 @@ load_elf_symbol_table(fd, image); free(programHeaders); + mutex_lock(&sImageMutex); register_elf_image(image); + mutex_unlock(&sImageMutex); done: _kern_close(fd); From mmlr at mail.berlios.de Tue Feb 19 01:42:54 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 19 Feb 2008 01:42:54 +0100 Subject: [Haiku-commits] r24011 - haiku/trunk/src/system/kernel Message-ID: <200802190042.m1J0gstv018503@sheep.berlios.de> Author: mmlr Date: 2008-02-19 01:42:54 +0100 (Tue, 19 Feb 2008) New Revision: 24011 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24011&view=rev Modified: haiku/trunk/src/system/kernel/heap.cpp Log: Fix bad error in calculating the leak check info address when updating the size of a reallocated block. If you had kernel heap leak checking on, this could have caused the first four bytes of the next block to be overwritten with the size of the reallocation of the previous block. Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-02-18 22:54:12 UTC (rev 24010) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-02-19 00:42:54 UTC (rev 24011) @@ -931,7 +931,8 @@ if (newSize > minSize && newSize <= maxSize) { #if KERNEL_HEAP_LEAK_CHECK // update the size info (the info is at the end so stays where it is) - heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + maxSize); + heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + + maxSize - sizeof(heap_leak_check_info)); info->size = newSize - sizeof(heap_leak_check_info); newSize -= sizeof(heap_leak_check_info); #endif From aldeck at mail.berlios.de Tue Feb 19 11:59:47 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Tue, 19 Feb 2008 11:59:47 +0100 Subject: [Haiku-commits] r24012 - haiku/trunk/build/jam Message-ID: <200802191059.m1JAxlo9020214@sheep.berlios.de> Author: aldeck Date: 2008-02-19 11:59:46 +0100 (Tue, 19 Feb 2008) New Revision: 24012 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24012&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: - add a home/config/settings/Keymap directory since the Keymap preflet needs it. (see line 89 to 99 in src/preferences/keymap/KeymapWindow.cpp ) Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-19 00:42:54 UTC (rev 24011) +++ haiku/trunk/build/jam/HaikuImage 2008-02-19 10:59:46 UTC (rev 24012) @@ -358,6 +358,7 @@ : /boot/beos/etc/timezones/Europe/Paris : timezone ; AddFilesToHaikuImage home config settings : US-International : Key_map ; +AddFilesToHaikuImage home config settings Keymap ; # bison files SEARCH on m4sugar.m4 From aldeck at mail.berlios.de Tue Feb 19 12:03:19 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Tue, 19 Feb 2008 12:03:19 +0100 Subject: [Haiku-commits] r24013 - haiku/trunk/build/jam Message-ID: <200802191103.m1JB3Ji7020613@sheep.berlios.de> Author: aldeck Date: 2008-02-19 12:03:19 +0100 (Tue, 19 Feb 2008) New Revision: 24013 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24013&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: - small mistake in my previous commit, sorry! Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-19 10:59:46 UTC (rev 24012) +++ haiku/trunk/build/jam/HaikuImage 2008-02-19 11:03:19 UTC (rev 24013) @@ -358,7 +358,7 @@ : /boot/beos/etc/timezones/Europe/Paris : timezone ; AddFilesToHaikuImage home config settings : US-International : Key_map ; -AddFilesToHaikuImage home config settings Keymap ; +AddDirectoryToHaikuImage home config settings Keymap ; # bison files SEARCH on m4sugar.m4 From korli at users.berlios.de Tue Feb 19 12:04:01 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 19 Feb 2008 12:04:01 +0100 Subject: [Haiku-commits] r24012 - haiku/trunk/build/jam In-Reply-To: <200802191059.m1JAxlo9020214@sheep.berlios.de> References: <200802191059.m1JAxlo9020214@sheep.berlios.de> Message-ID: Hi Aldeck, 2008/2/19, aldeck at BerliOS : > - add a home/config/settings/Keymap directory since the Keymap preflet needs it. (see line > 89 to 99 in src/preferences/keymap/KeymapWindow.cpp ) > Maybe a better idea would be to fix the preflet too :) Bye, J?r?me From alex at zappotek.com Tue Feb 19 12:09:53 2008 From: alex at zappotek.com (Alexandre Deckner) Date: Tue, 19 Feb 2008 12:09:53 +0100 Subject: [Haiku-commits] r24012 - haiku/trunk/build/jam In-Reply-To: References: <200802191059.m1JAxlo9020214@sheep.berlios.de> Message-ID: <47BAB901.8040502@zappotek.com> J?r?me Duval wrote : > Hi Aldeck, > > 2008/2/19, aldeck at BerliOS : > >> - add a home/config/settings/Keymap directory since the Keymap preflet needs it. (see line >> 89 to 99 in src/preferences/keymap/KeymapWindow.cpp ) >> >> > > Maybe a better idea would be to fix the preflet too :) > > Sure, i plan to do some work on it :) You mean, it would be preferable if the preflet itself created the dir if it's not there? Regards, Alex From alex at zappotek.com Tue Feb 19 12:18:36 2008 From: alex at zappotek.com (Alexandre Deckner) Date: Tue, 19 Feb 2008 12:18:36 +0100 Subject: [Haiku-commits] r24012 - haiku/trunk/build/jam In-Reply-To: <47BAB901.8040502@zappotek.com> References: <200802191059.m1JAxlo9020214@sheep.berlios.de> <47BAB901.8040502@zappotek.com> Message-ID: <47BABB0C.3010203@zappotek.com> Alexandre Deckner a ?crit : > J?r?me Duval wrote : > >> Hi Aldeck, >> >> 2008/2/19, aldeck at BerliOS : >> >> >>> - add a home/config/settings/Keymap directory since the Keymap preflet needs it. (see line >>> 89 to 99 in src/preferences/keymap/KeymapWindow.cpp ) >>> >>> >>> >> Maybe a better idea would be to fix the preflet too :) >> >> >> > Sure, i plan to do some work on it :) > You mean, it would be preferable if the preflet itself created the dir > if it's not there? > > Oh well, i've got my answer i guess ;-) R5's one creates it if it's not there... Will fix this Regards, Alex From stippi at mail.berlios.de Tue Feb 19 12:32:44 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 19 Feb 2008 12:32:44 +0100 Subject: [Haiku-commits] r24014 - haiku/trunk/src/servers/input Message-ID: <200802191132.m1JBWi0B026370@sheep.berlios.de> Author: stippi Date: 2008-02-19 12:32:41 +0100 (Tue, 19 Feb 2008) New Revision: 24014 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24014&view=rev Modified: haiku/trunk/src/servers/input/InputServer.cpp haiku/trunk/src/servers/input/InputServer.h Log: Fixed the log file output when DEBUG=2. PRINT() is called from global initializers before sLogFile was created in the InputServer constructor. Even moving the log file creation to a global initializer didn't help, since the order is not guaranteed. So I changed the code to create the log file on the fly in the PRINT method. Modified: haiku/trunk/src/servers/input/InputServer.cpp =================================================================== --- haiku/trunk/src/servers/input/InputServer.cpp 2008-02-19 11:03:19 UTC (rev 24013) +++ haiku/trunk/src/servers/input/InputServer.cpp 2008-02-19 11:32:41 UTC (rev 24014) @@ -60,11 +60,7 @@ KeymapMethod InputServer::gKeymapMethod; -#if DEBUG == 2 -FILE *InputServer::sLogFile = NULL; -#endif - extern "C" _EXPORT BView* instantiate_deskbar_item(); @@ -147,11 +143,6 @@ fAppServerPort(-1), fCursorArea(-1) { -#if DEBUG == 2 - if (sLogFile == NULL) - sLogFile = fopen("/var/log/input_server.log", "a"); -#endif - CALLED(); gInputServer = this; @@ -225,10 +216,6 @@ fAddOnManager->Quit(); _ReleaseInput(NULL); - -#if DEBUG == 2 - fclose(sLogFile); -#endif } Modified: haiku/trunk/src/servers/input/InputServer.h =================================================================== --- haiku/trunk/src/servers/input/InputServer.h 2008-02-19 11:03:19 UTC (rev 24013) +++ haiku/trunk/src/servers/input/InputServer.h 2008-02-19 11:32:41 UTC (rev 24014) @@ -42,7 +42,8 @@ class InputDeviceListItem { public: - InputDeviceListItem(BInputServerDevice& serverDevice, input_device_ref& device); + InputDeviceListItem(BInputServerDevice& serverDevice, + input_device_ref& device); void Start(); void Stop(); @@ -75,7 +76,8 @@ class _BMethodAddOn_ { public: - _BMethodAddOn_(BInputServerMethod *method, const char* name, const uchar* icon); + _BMethodAddOn_(BInputServerMethod *method, const char* name, + const uchar* icon); ~_BMethodAddOn_(); status_t SetName(const char* name); @@ -236,10 +238,6 @@ uint32* fCursorBuffer; #endif -#if DEBUG == 2 - public: - static FILE *sLogFile; -#endif }; extern InputServer* gInputServer; @@ -247,8 +245,17 @@ #if DEBUG >= 1 # if DEBUG == 2 # undef PRINT - inline void _iprint(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \ - fputs(buf, InputServer::sLogFile); fflush(InputServer::sLogFile); } + inline void _iprint(const char *fmt, ...) { + FILE* log = fopen("/var/log/input_server.log", "a"); + char buf[1024]; + va_list ap; + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + fputs(buf, log); + fflush(log); + fclose(log); + } # define PRINT(x) _iprint x # else # undef PRINT From axeld at pinc-software.de Tue Feb 19 12:32:42 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 19 Feb 2008 12:32:42 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23939_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel_src/system/kernel__src/system/kernel/vm?= In-Reply-To: <200802102100.m1AL0F71017229@sheep.berlios.de> Message-ID: <5067735878-BeMail@zon> mmlr at BerliOS wrote: > Log: > Complete rework of the heap implementation. Nice work! I would rather have you seen working on getting our existing slab allocator to work as a heap, but I guess this will keep us going for a while :-) Bye, Axel. From marcusoverhagen at arcor.de Tue Feb 19 13:04:15 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Tue, 19 Feb 2008 13:04:15 +0100 (CET) Subject: [Haiku-commits] r24014 - haiku/trunk/src/servers/input In-Reply-To: <200802191132.m1JBWi0B026370@sheep.berlios.de> References: <200802191132.m1JBWi0B026370@sheep.berlios.de> Message-ID: <28476982.1203422655823.JavaMail.ngmail@webmail11> stippi at BerliOS wrote: > + char buf[1024]; > + va_list ap; > + va_start(ap, fmt); > + vsprintf(buf, fmt, ap); > + va_end(ap); > + fputs(buf, log); You can avoid allocationg the buffer using vfprintf. va_list ap; va_start(ap, fmt); vfprintf(log, fmt, ap); va_end(ap); regards Marcus Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From aldeck at mail.berlios.de Tue Feb 19 13:43:52 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Tue, 19 Feb 2008 13:43:52 +0100 Subject: [Haiku-commits] r24015 - in haiku/trunk: build/jam src/preferences/keymap Message-ID: <200802191243.m1JChqNW016474@sheep.berlios.de> Author: aldeck Date: 2008-02-19 13:43:52 +0100 (Tue, 19 Feb 2008) New Revision: 24015 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24015&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/preferences/keymap/KeymapWindow.cpp Log: - fixes the Keymap preflet instead, as suggested by korli. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-19 11:32:41 UTC (rev 24014) +++ haiku/trunk/build/jam/HaikuImage 2008-02-19 12:43:52 UTC (rev 24015) @@ -358,7 +358,6 @@ : /boot/beos/etc/timezones/Europe/Paris : timezone ; AddFilesToHaikuImage home config settings : US-International : Key_map ; -AddDirectoryToHaikuImage home config settings Keymap ; # bison files SEARCH on m4sugar.m4 Modified: haiku/trunk/src/preferences/keymap/KeymapWindow.cpp =================================================================== --- haiku/trunk/src/preferences/keymap/KeymapWindow.cpp 2008-02-19 11:32:41 UTC (rev 24014) +++ haiku/trunk/src/preferences/keymap/KeymapWindow.cpp 2008-02-19 12:43:52 UTC (rev 24015) @@ -93,6 +93,11 @@ entry_ref ref; get_ref_for_path(path.Path(), &ref); + BDirectory userKeymapsDir(&ref); + if (userKeymapsDir.InitCheck() != B_OK) { + create_directory(path.Path(), 0777); + } + fOpenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), &ref, B_FILE_NODE, false, NULL); fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), &ref, From mmlr at mlotz.ch Tue Feb 19 14:08:40 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Tue, 19 Feb 2008 14:08:40 +0100 Subject: [Haiku-commits] r23939 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <5067735878-BeMail@zon> References: <200802102100.m1AL0F71017229@sheep.berlios.de> <5067735878-BeMail@zon> Message-ID: <20080219130749.M28765@mlotz.ch> On Tue, 19 Feb 2008 12:32:42 +0100 CET, Axel D?rfler wrote > mmlr at BerliOS wrote: > > Log: > > Complete rework of the heap implementation. > > Nice work! I would rather have you seen working on getting our > existing slab allocator to work as a heap, but I guess this will > keep us going for a while :-) I started out with looking at that code, but for such a low level task it is quite a bit too complex IMHO. The problem is that the heap is used even in the area code, so it forms the absolute lowest primitive in memory management. Even though the current slab has functionality to manage memory without depending on areas it would probably need some work the get it going as a heap replacement that performs as efficient. The reworked heap on the other hand is now pretty straight forward and does not have any dependencies. It is also very efficient and flexible for small allocations up to one page. I doubt that switching to a more complex implementation for these would bring any real benefit. Also since the heaps can simply be attached to memory ranges, it is easily possible to implement additional features, like to create allocators tied to CPUs to reduce false cache line sharing. It would be a simple extension to the current memalign() function. For this to be useful though, we first need some CPU affinity, so that threads do not constantly migrate and could actually make use a CPU specific allocator. On the large allocation front (bigger than one page) the heap is currently not that efficient though. It works well, but there are some linear searches involved that do not scale (though I still have some ideas to speed that up). So a useful thing for the future would be to move to a "dual allocator" approach, where the heap is used for all small allocations and a slab or other allocator for everything else. From my observations, the vast majority of allocations is in the very small area though, so for large allocations it could even be argued to simply create areas. By the way there are now leak checking functions implemented that can track open allocations and filter by team or thread id (has to be enabled by the corresponding define at the top of heap.cpp). Also combined with heap tracing it is possible to easily get the context of allocations to help find out where the leak started. I found one in BFS this way and hope that it will be useful to others too. Regards Michael From axeld at pinc-software.de Tue Feb 19 15:20:00 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 19 Feb 2008 15:20:00 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23939_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel_src/system/kernel__src/system/kernel/vm?= In-Reply-To: <20080219130749.M28765@mlotz.ch> Message-ID: <15105322275-BeMail@zon> "Michael Lotz" wrote: > On Tue, 19 Feb 2008 12:32:42 +0100 CET, Axel D?rfler wrote > > Nice work! I would rather have you seen working on getting our > > existing slab allocator to work as a heap, but I guess this will > > keep us going for a while :-) > I started out with looking at that code, but for such a low level > task it is > quite a bit too complex IMHO. The problem is that the heap is used > even in the > area code, so it forms the absolute lowest primitive in memory > management. > Even though the current slab has functionality to manage memory > without > depending on areas it would probably need some work the get it going > as a heap > replacement that performs as efficient. It definitely needs some work, yes. I still think it's worth it, though :-) > The reworked heap on the other hand is now pretty straight forward > and does > not have any dependencies. It is also very efficient and flexible for > small Actually, it has very similar dependencies - both need areas to work with. If your 2 MB grow heap is empty, we're screwed, too, right? The same approach would work (for some time) for the slab allocator. > allocations up to one page. I doubt that switching to a more complex > implementation for these would bring any real benefit. Also since the > heaps > can simply be attached to memory ranges, it is easily possible to > implement > additional features, like to create allocators tied to CPUs to reduce > false > cache line sharing. It would be a simple extension to the current > memalign() > function. For this to be useful though, we first need some CPU > affinity, so > that threads do not constantly migrate and could actually make use a > CPU > specific allocator. A CPU specific allocator also has the advantage that you can allocate and free resources lockless; CPU affinity is definitely a plus in this scenario, too, but it's not mandatory. > On the large allocation front (bigger than one page) the heap is > currently not > that efficient though. It works well, but there are some linear > searches > involved that do not scale (though I still have some ideas to speed > that up). > So a useful thing for the future would be to move to a "dual > allocator" > approach, where the heap is used for all small allocations and a slab > or other > allocator for everything else. From my observations, the vast > majority of > allocations is in the very small area though, so for large > allocations it > could even be argued to simply create areas. The slab allocator is very efficient for both, small allocations and large allocations, depending on how the underlying memory allocation is working (right now, it's not so good, because area creation is expansive). Anyway, in the long run I would like to have only one allocator if possible. It's not as urgent anymore now, though. > By the way there are now leak checking functions implemented that can > track > open allocations and filter by team or thread id (has to be enabled > by the > corresponding define at the top of heap.cpp). Also combined with heap > tracing > it is possible to easily get the context of allocations to help find > out where > the leak started. I found one in BFS this way and hope that it will > be useful > to others too. I noticed, and already turned that feature on :-) Bye, Axel. From korli at users.berlios.de Tue Feb 19 15:26:46 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 19 Feb 2008 15:26:46 +0100 Subject: [Haiku-commits] r24015 - in haiku/trunk: build/jam src/preferences/keymap In-Reply-To: <200802191243.m1JChqNW016474@sheep.berlios.de> References: <200802191243.m1JChqNW016474@sheep.berlios.de> Message-ID: Alexandre, 2008/2/19, aldeck at BerliOS : > + create_directory(path.Path(), 0777); Could you replace 0777 with S_IRWXU | S_IRWXG | S_IRWXO ? Just an idea. Bye, J?r?me From alex at zappotek.com Tue Feb 19 15:43:04 2008 From: alex at zappotek.com (Alexandre Deckner) Date: Tue, 19 Feb 2008 15:43:04 +0100 Subject: [Haiku-commits] r24015 - in haiku/trunk: build/jam src/preferences/keymap In-Reply-To: References: <200802191243.m1JChqNW016474@sheep.berlios.de> Message-ID: <47BAEAF8.5050000@zappotek.com> J?r?me Duval wrote : > Alexandre, > > 2008/2/19, aldeck at BerliOS : > >> + create_directory(path.Path(), 0777); >> > > Could you replace 0777 with S_IRWXU | S_IRWXG | S_IRWXO ? Just an idea. > > > Ohh, pretty! Will do! What about those: http://haiku.it.su.se:8180/source/search?n=25&start=0&refs=create_directory :-O Alex From axeld at mail.berlios.de Tue Feb 19 15:59:33 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 19 Feb 2008 15:59:33 +0100 Subject: [Haiku-commits] r24016 - haiku/trunk/src/system/kernel/fs Message-ID: <200802191459.m1JExXVK002523@sheep.berlios.de> Author: axeld Date: 2008-02-19 15:59:30 +0100 (Tue, 19 Feb 2008) New Revision: 24016 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24016&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: * Simplified devfs_rescan_driver() since the driver hash is now based on the name of the drivers. * Allow driver::publish_devices() to return NULL to hint that it has no devices to publish anymore (ie. existing devices will be unpublished in this case). * republish_driver() now also calls load_driver() in case the driver is not loaded. * publish_device() and unpublish_node() now maintain the new driver_entry::devices_published field, so we always know how many devices a driver has now. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-19 12:43:52 UTC (rev 24015) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-19 14:59:30 UTC (rev 24016) @@ -130,6 +130,7 @@ ino_t node; time_t last_modified; image_id image; + uint32 devices_published; // driver image information int32 *api_version; @@ -781,6 +782,11 @@ status = remove_vnode(fs->id, node->id); + if (status == B_OK && S_ISCHR(node->stream.type) + && node->stream.u.dev.driver != NULL) { + node->stream.u.dev.driver->devices_published--; + } + out: recursive_lock_unlock(&fs->lock); return status; @@ -1007,6 +1013,9 @@ node->stream.u.dev.driver = driver; node->stream.u.dev.ops = ops; + if (driver != NULL) + driver->devices_published++; + // every raw disk gets an I/O scheduler object attached // ToDo: the driver should ask for a scheduler (ie. using its devfs node attributes) if (isDisk && !strcmp(node->name, "raw")) { @@ -1015,41 +1024,49 @@ return B_NO_MEMORY; } - return status; + return B_OK; } +/*! Collects all published devices of a driver, compares them to what the + driver would publish now, and then publishes/unpublishes the devices + as needed. + If the driver does not publish any devices anymore, it is unloaded. +*/ static status_t republish_driver(driver_entry *driver) { - if (driver->image < 0) - return B_NO_INIT; + if (driver->image < 0) { + // The driver is not yet loaded - go through the normal load procedure + return load_driver(driver); + } RecursiveLocker locker(&sDeviceFileSystem->lock); - // build the list of currently present devices by iterating through all - // present nodes + // build the list of currently present devices of this driver + // by iterating through all present nodes struct hash_iterator i; hash_open(sDeviceFileSystem->vnode_hash, &i); - devfs_vnode *vnode = (devfs_vnode *)hash_next( - sDeviceFileSystem->vnode_hash, &i); - DoublyLinkedList currentNodes; - while (vnode) { - if (S_ISCHR(vnode->stream.type)) { - if (vnode->stream.u.dev.driver == driver) { - node_path_entry *path = new(std::nothrow) node_path_entry; - if (!path) { - while ((path = currentNodes.RemoveHead())) - delete path; - hash_close(sDeviceFileSystem->vnode_hash, &i, false); - return B_NO_MEMORY; - } + while (true) { + devfs_vnode *vnode = (devfs_vnode *)hash_next( + sDeviceFileSystem->vnode_hash, &i); + if (vnode == NULL) + break; - get_device_name(vnode, path->path, sizeof(path->path)); - currentNodes.Add(path); + if (S_ISCHR(vnode->stream.type) + && vnode->stream.u.dev.driver == driver) { + node_path_entry *path = new(std::nothrow) node_path_entry; + if (!path) { + while ((path = currentNodes.RemoveHead())) + delete path; + hash_close(sDeviceFileSystem->vnode_hash, &i, false); + return B_NO_MEMORY; } + + get_device_name(vnode, path->path, sizeof(path->path)); + currentNodes.Add(path); } vnode = (devfs_vnode *)hash_next(sDeviceFileSystem->vnode_hash, &i); @@ -1058,15 +1075,9 @@ // now ask the driver for it's currently published devices const char **devicePaths = driver->publish_devices(); - if (devicePaths == NULL) { - node_path_entry *entry = NULL; - while ((entry = currentNodes.RemoveHead())) - delete entry; - return B_ERROR; - } int32 exported = 0; - for (; devicePaths[0]; devicePaths++) { + for (; devicePaths != NULL && devicePaths[0]; devicePaths++) { bool present = false; node_path_entry *entry = currentNodes.Head(); while (entry) { @@ -2620,33 +2631,11 @@ RecursiveLocker locker(&sDeviceFileSystem->lock); - // iterate over the drivers and search a matching driverName - struct hash_iterator i; - hash_open(sDeviceFileSystem->driver_hash, &i); + driver_entry *driver = (driver_entry *)hash_lookup( + sDeviceFileSystem->driver_hash, driverName); + if (driver == NULL) + return B_ENTRY_NOT_FOUND; - driver_entry *driver = (driver_entry *)hash_next( - sDeviceFileSystem->driver_hash, &i); - while (driver) { - const char *name = strrchr(driver->path, '/'); - if (name == NULL) - name = driver->path; - else - name++; - - if (!strcmp(name, driverName)) { - hash_close(sDeviceFileSystem->driver_hash, &i, false); - if (driver->image < 0) { - // The driver is not yet loaded - return load_driver(driver); - } else { - // The driver is loaded, just republish its entries - return republish_driver(driver); - } - } - - driver = (driver_entry *)hash_next(sDeviceFileSystem->driver_hash, &i); - } - - hash_close(sDeviceFileSystem->driver_hash, &i, false); - return B_ENTRY_NOT_FOUND; + // Republish the driver's entries + return republish_driver(driver); } From korli at users.berlios.de Tue Feb 19 16:17:22 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 19 Feb 2008 16:17:22 +0100 Subject: [Haiku-commits] r23939 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <15105322275-BeMail@zon> References: <20080219130749.M28765@mlotz.ch> <15105322275-BeMail@zon> Message-ID: 2008/2/19, Axel D?rfler : > > Even though the current slab has functionality to manage memory > > without > > depending on areas it would probably need some work the get it going > > as a heap > > replacement that performs as efficient. > > It definitely needs some work, yes. I still think it's worth it, though > :-) > To clear my mind, the modified heap allocator is the one only for the kernel, no ? Is there another one for userland ? Bye, J?r?me From revol at free.fr Tue Feb 19 16:51:58 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Tue, 19 Feb 2008 16:51:58 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23939_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/private/kernel_src/system/kernel__src/system/kernel/v?= =?windows-1252?q?m?= In-Reply-To: <20080219130749.M28765@mlotz.ch> Message-ID: <1710239734-BeMail@laptop> > On Tue, 19 Feb 2008 12:32:42 +0100 CET, Axel D?rfler wrote > > mmlr at BerliOS wrote: > > > Log: > > > Complete rework of the heap implementation. > > > > Nice work! I would rather have you seen working on getting our > > existing slab allocator to work as a heap, but I guess this will > > keep us going for a while :-) I was about to ask :) > The reworked heap on the other hand is now pretty straight forward > and does > not have any dependencies. It is also very efficient and flexible for > small > allocations up to one page. I doubt that switching to a more complex > implementation for these would bring any real benefit. Also since the > heaps > can simply be attached to memory ranges, it is easily possible to > implement > additional features, like to create allocators tied to CPUs to reduce > false > cache line sharing. It would be a simple extension to the current > memalign() > function. For this to be useful though, we first need some CPU > affinity, so > that threads do not constantly migrate and could actually make use a > CPU > specific allocator. Linux uses something alike to support NUMA, though more at the vm level. It uses a list of memory descriptors listing available dma, low and high mem for each node and its cost, so that it chooses memory that is directly on the current cpu bus and doesn't force using inter node bus to access it. > On the large allocation front (bigger than one page) the heap is > currently not > that efficient though. It works well, but there are some linear > searches > involved that do not scale (though I still have some ideas to speed > that up). Well I just wanted it to work when I did that reuse part :p > So a useful thing for the future would be to move to a "dual > allocator" > approach, where the heap is used for all small allocations and a slab > or other > allocator for everything else. From my observations, the vast > majority of > allocations is in the very small area though, so for large > allocations it > could even be argued to simply create areas. > > By the way there are now leak checking functions implemented that can > track > open allocations and filter by team or thread id (has to be enabled > by the > corresponding define at the top of heap.cpp). Also combined with heap > tracing > it is possible to easily get the context of allocations to help find > out > where the leak started. I found one in BFS this way and hope that it > will be useful > to others too. Maybe we might want to trace allocs by module/driver, as each are supposed to free what they asked for. It should be possible to look up the return address (gcc has a function for that, __builtin_return_address()). Then use a trick I usually employ to find ressources for replicants (where the app isn't what we want). Just walk the image list and check the address against the text segment until one matches. Fran?ois. From axeld at mail.berlios.de Tue Feb 19 17:00:14 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 19 Feb 2008 17:00:14 +0100 Subject: [Haiku-commits] r24017 - haiku/trunk/src/tests/system/kernel Message-ID: <200802191600.m1JG0EHw007881@sheep.berlios.de> Author: axeld Date: 2008-02-19 17:00:11 +0100 (Tue, 19 Feb 2008) New Revision: 24017 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24017&view=rev Added: haiku/trunk/src/tests/system/kernel/advisory_locking_test.cpp Modified: haiku/trunk/src/tests/system/kernel/Jamfile Log: Added test program for our advisory locking implementation - looks like it has several issues, and a F_UNLCK semantic different from other OSs, causing bug #1791. Modified: haiku/trunk/src/tests/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/Jamfile 2008-02-19 14:59:30 UTC (rev 24016) +++ haiku/trunk/src/tests/system/kernel/Jamfile 2008-02-19 16:00:11 UTC (rev 24017) @@ -3,6 +3,8 @@ UsePrivateHeaders kernel ; UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; +SimpleTest advisory_locking_test : advisory_locking_test.cpp ; + SimpleTest cow_bug113_test : cow_bug113_test.cpp ; SimpleTest fibo_load_image : fibo_load_image.cpp ; Added: haiku/trunk/src/tests/system/kernel/advisory_locking_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/advisory_locking_test.cpp 2008-02-19 14:59:30 UTC (rev 24016) +++ haiku/trunk/src/tests/system/kernel/advisory_locking_test.cpp 2008-02-19 16:00:11 UTC (rev 24017) @@ -0,0 +1,139 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include +#include +#include +#include + + +extern const char *__progname; + +const char* kTemporaryFile = "/tmp/axels-lock-test"; + + +const char* +type_name(int type) +{ + return type == F_RDLCK ? "shared" : type == F_WRLCK + ? "exclusive" : "remove"; +} + + +int +do_lock(int fd, int type, off_t start, off_t length) +{ + printf("%s lock %Ld:%Ld\n", type_name(type), start, length); + + struct flock flock; + flock.l_type = type; + flock.l_whence = SEEK_SET; + flock.l_start = start; + flock.l_len = length; + if (fcntl(fd, F_SETLK, &flock) != 0) { + fprintf(stderr, "ERROR: %s lock %Ld:%Ld failed: %s\n", type_name(type), + start, length, strerror(errno)); + return -1; + } + + return 0; +} + + +int +shared_lock(int fd, off_t start, off_t length) +{ + return do_lock(fd, F_RDLCK, start, length); +} + + +int +exclusive_lock(int fd, off_t start, off_t length) +{ + return do_lock(fd, F_WRLCK, start, length); +} + + +int +remove_lock(int fd, off_t start, off_t length) +{ + return do_lock(fd, F_UNLCK, start, length); +} + + +void +wait_for_enter() +{ + puts("wait for ..."); + char buffer[64]; + fgets(buffer, sizeof(buffer), stdin); +} + + +void +usage() +{ + fprintf(stderr, "usage: %s [shared|exclusive|unlock ] " + "[wait] [...]\n", __progname); + exit(1); +} + + +bool +is_command(const char* op, const char* command1, const char* command2) +{ + int length = strlen(op); + if (length == 0) + return false; + + return command1 != NULL && !strncmp(op, command1, length) + || command2 != NULL && !strncmp(op, command2, length); +} + + +int +main(int argc, char** argv) +{ + int fd = open(kTemporaryFile, O_CREAT | O_RDWR, 0644); + if (fd < 0) { + fprintf(stderr, "Could not create lock file: %s\n", strerror(errno)); + return 1; + } + + while (argc > 1) { + const char* op = argv[1]; + if (is_command(op, "wait", NULL)) { + wait_for_enter(); + argv++; + argc--; + continue; + } + if (argc < 3) + usage(); + + off_t start = strtoll(argv[2], NULL, 0); + off_t length = strtoll(argv[3], NULL, 0); + int type = 0; + if (is_command(op, "read", "shared")) + type = F_RDLCK; + else if (is_command(op, "write", "exclusive")) + type = F_WRLCK; + else if (is_command(op, "unlock", "remove")) + type = F_UNLCK; + else + usage(); + + do_lock(fd, type, start, length); + argc -= 3; + argv += 3; + } + + close(fd); + return 0; +} + From stippi at mail.berlios.de Tue Feb 19 17:03:15 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 19 Feb 2008 17:03:15 +0100 Subject: [Haiku-commits] r24018 - haiku/trunk/src/add-ons/input_server/devices/wacom Message-ID: <200802191603.m1JG3F5g008579@sheep.berlios.de> Author: stippi Date: 2008-02-19 17:03:15 +0100 (Tue, 19 Feb 2008) New Revision: 24018 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24018&view=rev Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.cpp haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.h haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.h haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.cpp haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.h Log: * Reworked debugging feature, it's now much more simple to use, copied from the input_server implementation to create a log file. * DeviceReader already provided the data byte count, since this is a USB only Wacom driver, we can simply use the max_packet_size from the endpoint descriptor. Changed TabledDevice accordingly to use the already existing DeviceReader::MaxPacketSize(). * Reworked DeviceReader::ReadData(). Renamed variables for clarity and removed the restriction to read exactly the requested ammount of bytes, reading more than the "header" (which contains vendor id, product id and max packet size) is already considered a successful read. * Refactored TabledDevice::poll_usb_device(). Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.cpp 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.cpp 2008-02-19 16:03:15 UTC (rev 24018) @@ -9,7 +9,12 @@ #include +#include "MasterServerDevice.h" + +static ssize_t kHeaderSize = 8; + + // constructor DeviceReader::DeviceReader() : fDevicePath(NULL), @@ -39,9 +44,9 @@ if (ret >= B_OK) { // read 8 bytes from the file and initialize // the rest of the object variables - uint8 buffer[8]; - ret = fDeviceFile->Read(buffer, 8); - if (ret == 8) { + uint8 buffer[kHeaderSize]; + ret = fDeviceFile->Read(buffer, kHeaderSize); + if (ret == kHeaderSize) { ret = B_OK; uint16* ids = (uint16*)buffer; fVendorID = ids[0]; @@ -99,33 +104,43 @@ } // ReadData -status_t -DeviceReader::ReadData(uint8* data, size_t size) const +ssize_t +DeviceReader::ReadData(uint8* data, const size_t size) const { - status_t ret = B_NO_INIT; - if (fDeviceFile) { - ret = fDeviceFile->InitCheck(); - if (ret >= B_OK) { - uint8* buffer = new uint8[fMaxPackedSize + 8]; - ret = fDeviceFile->Read(buffer, fMaxPackedSize + 8); - if (ret == (ssize_t)(fMaxPackedSize + 8)) { - // make sure we don't copy too many bytes - size_t length = min_c(size, fMaxPackedSize); - memcpy(data, buffer + 8, length); - // zero out any remaining bytes - if (size > fMaxPackedSize) - memset(data + length, 0, size - fMaxPackedSize); - // operation could be considered successful - ret = length; - } else if (ret == 8 || ret == B_TIMED_OUT) { - // it's ok if the operation timed out - memset(data, 0, size); - ret = B_OK; - } - delete[] buffer; - } + if (!fDeviceFile || fMaxPackedSize <= 0 || fMaxPackedSize > 128) + return B_NO_INIT; + status_t ret = fDeviceFile->InitCheck(); + if (ret < B_OK) + return (ssize_t)ret; + + ssize_t requested = fMaxPackedSize + kHeaderSize; + uint8 buffer[requested]; + ssize_t read = fDeviceFile->Read(buffer, requested); + if (read > kHeaderSize) { + // make sure we don't copy too many bytes + size_t bytesToCopy = min_c(size, read - (size_t)kHeaderSize); +PRINT(("requested: %ld, read: %ld, user wants: %lu, copy bytes: %ld\n", + requested, read, size, bytesToCopy)); + memcpy(data, buffer + kHeaderSize, bytesToCopy); + // zero out any remaining bytes + if (size > bytesToCopy) + memset(data + bytesToCopy, 0, size - bytesToCopy); + // operation could be considered successful +// read = bytesToCopy; +// if (read != (ssize_t)size) +// PRINT(("user wanted: %lu, returning: %ld\n", size, read)); + read = size; + // pretend we could read as many bytes as requested + } else if (read == kHeaderSize || (status_t)read == B_TIMED_OUT) { + // it's ok if the operation timed out + memset(data, 0, size); + read = (size_t)B_OK; + } else { + PRINT(("requested: %ld, read: %ld, user wants: %lu\n", + requested, read, size)); } - return ret; + + return read; } // _Unset Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.h =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.h 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/DeviceReader.h 2008-02-19 16:03:15 UTC (rev 24018) @@ -45,8 +45,10 @@ size_t MaxPacketSize() const; // trigger an interrupt transfer and write the data in the buffer - // it should be save to call this function with size != MaxPacketSize - status_t ReadData(uint8* data, size_t size) const; + // it should be save to call this function with + // size != MaxPacketSize, remaining bytes will be zero'd out + ssize_t ReadData(uint8* data, + const size_t size) const; protected: void _Unset(); Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp 2008-02-19 16:03:15 UTC (rev 24018) @@ -25,15 +25,9 @@ #define DEFAULT_CLICK_SPEED 250000 -#define DEBUG 0 - static const char* kWatchFolder = "input/wacom/usb"; static const char* kDeviceFolder = "/dev/input/wacom/usb"; -#if DEBUG -static const char* kLogFilePath = "/tmp/wacom.log"; -#endif - //static const char* kPS2MouseThreadName = "PS/2 Mouse"; // instantiate_input_device @@ -50,7 +44,6 @@ : BInputServerDevice(), fDevices(1), fActive(false), - fLogString(""), fDblClickSpeed(DEFAULT_CLICK_SPEED), fPS2DisablerThread(B_ERROR), fDeviceLock("device list lock") @@ -96,10 +89,7 @@ _StopAll(); -#if DEBUG - fLogString << "---------------------------------\n\n"; - DumpLogString(kLogFilePath); -#endif + PRINT(("---------------------------------\n\n")); return (BInputServerDevice::SystemShuttingDown()); } @@ -170,30 +160,6 @@ return B_OK; } -// LogDataBytes -void -MasterServerDevice::LogDataBytes(uchar* data, int bytes) -{ - for (int32 i = 0; i < bytes; i += 2) - fLogString << (uint32)data[i] << " " << (uint32)data[i + 1] << " "; - fLogString << "\n"; -} - -// DumpLogString -void -MasterServerDevice::DumpLogString(const char* path) -{ - if (fLogString.Length() > 0) { - BFile logFile(path, B_WRITE_ONLY | B_CREATE_FILE); - if (logFile.InitCheck() >= B_OK) { - logFile.Seek(0, SEEK_END); - logFile.Write(fLogString.String(), fLogString.Length()); - fLogString.SetTo(""); - } - logFile.Unset(); - } -} - // #pragma mark - // _SearchDevices @@ -208,12 +174,8 @@ // entry of that device still exists entry_ref ref; while (dir.GetNextRef(&ref) >= B_OK) { + PRINT(("examining devfs entry '%s'\n", ref.name)); // don't add the control device - -#if DEBUG - fLogString << "examining devfs entry '" << ref.name << "'\n"; -#endif - if (strcmp(ref.name, "control") != 0) { BPath path(&ref); if (path.InitCheck() >= B_OK) { @@ -221,24 +183,11 @@ _AddDevice(path.Path()); } } - -#if DEBUG - fLogString << "\n"; -#endif - } - } else { + } else + PRINT(("folder '%s' not found\n", kDeviceFolder)); -#if DEBUG - fLogString << "folder '" << kDeviceFolder <<"' not found\n"; -#endif - - } - -#if DEBUG - fLogString << "done examing devfs\n"; - DumpLogString("kLogFilePath"); -#endif + PRINT(("done examing devfs\n")); _UnlockDevices(); } } @@ -265,27 +214,17 @@ // add it to our list if (device && device->InitCheck() >= B_OK && fDevices.AddItem((void*)device)) { - -#if DEBUG - fLogString << "pointing device added (" << path << ")\n"; -// DumpLogString("kLogFilePath"); -#endif - + PRINT(("pointing device added (%s)\n", path)); // start device polling only if we're started if (fActive) device->Start(); } else { -#if DEBUG - fLogString << "pointing device not added (" << path << ")\n"; - if (device) { - char temp[256]; - sprintf(temp, " vendor: %0*x, product: %0*x\n", 4, device->VendorID(), - 4, device->ProductID()); - fLogString << temp; - } -// DumpLogString("kLogFilePath"); -#endif + PRINT(("pointing device not added (%s)\n", path)); + if (device) { + PRINT((" vendor: %0*x, product: %0*x\n", 4, device->VendorID(), + 4, device->ProductID())); + } delete device; } @@ -348,9 +287,7 @@ // remove the device if the devfs entry was not found if (!found) { -#if DEBUG -fLogString << "removing device '" << pointingDevice->DevicePath() << "'\n"; -#endif + PRINT(("removing device '%s'\n", pointingDevice->DevicePath())); if (_LockDevices()) { if (fDevices.RemoveItem((void*)pointingDevice)) Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.h =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.h 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/MasterServerDevice.h 2008-02-19 16:03:15 UTC (rev 24018) @@ -5,6 +5,8 @@ #ifndef MASTER_SERVER_DEVICE_H #define MASTER_SERVER_DEVICE_H +#include + #include #include #include @@ -35,12 +37,6 @@ const float* AccelerationTable() const { return fAccelerationTable; } - // debugging - inline BString& LogString() - { return fLogString; } - void LogDataBytes(uchar* data, int bytes); - void DumpLogString(const char* path); - private: void _SearchDevices(); @@ -63,9 +59,6 @@ BList fDevices; volatile bool fActive; - // debugging - BString fLogString; - // global stuff for all mice objects int32 fSpeed; int32 fAcceleration; @@ -77,4 +70,25 @@ BLocker fDeviceLock; }; +#ifndef DEBUG +# define DEBUG 0 +#endif + +#if DEBUG +# undef PRINT + inline void _iprint(const char* fmt, ...) { + FILE* log = fopen("/var/log/wacom.log", "a"); + va_list ap; + va_start(ap, fmt); + vfprintf(log, fmt, ap); + va_end(ap); + fflush(log); + fclose(log); + } +# define PRINT(x) _iprint x +#else +# define PRINT(x) +#endif + + #endif // MASTER_SERVER_DEVICE_H Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.cpp 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.cpp 2008-02-19 16:03:15 UTC (rev 24018) @@ -31,8 +31,6 @@ #define JITTER_Y .0007 #define ACCELERATION_KICK_IN 2.3 -#define DEBUG 0 - // constructor TabletDevice::TabletDevice(MasterServerDevice* parent, DeviceReader* reader) : PointingDevice(parent, reader), @@ -40,7 +38,6 @@ fDeviceMode(DEVICE_UNKOWN), fMaxX(1.0), fMaxY(1.0), - fDataBytes(10), fPosX(0.5), fPosY(0.5), fFakeMouseX(0.5), @@ -69,7 +66,7 @@ { status_t status = PointingDevice::InitCheck(); if (status >= B_OK) - status = DetectDevice(fReader->ProductID()); + status = DetectDevice(fReader); return status; } @@ -110,35 +107,35 @@ // DetectDevice status_t -TabletDevice::DetectDevice(uint16 product) +TabletDevice::DetectDevice(const DeviceReader* reader) { status_t status = B_OK; - switch (product) { + switch (reader->ProductID()) { case 0x00: - SetDevice(5040.0, 3780.0, DEVICE_PENPARTNER, 7); + SetDevice(5040.0, 3780.0, DEVICE_PENPARTNER); break; case 0x03: - SetDevice(2048.0, 15360.0, DEVICE_PL500, 8); + SetDevice(2048.0, 15360.0, DEVICE_PL500); break; case 0x10: case 0x11: case 0x13: - SetDevice(10206.0, 7422.0, DEVICE_GRAPHIRE, 8); + SetDevice(10206.0, 7422.0, DEVICE_GRAPHIRE); break; case 0x12: // Graphire 3 4x5 - SetDevice(13918.0, 10206.0, DEVICE_GRAPHIRE, 8); + SetDevice(13918.0, 10206.0, DEVICE_GRAPHIRE); break; case 0x14: // Graphire 3 6x8 - SetDevice(16704.0, 12064.0, DEVICE_GRAPHIRE, 8); + SetDevice(16704.0, 12064.0, DEVICE_GRAPHIRE); break; case 0x15: // Graphire 4 4x5 (tested) - SetDevice(10208.0, 7024.0, DEVICE_GRAPHIRE, 8); + SetDevice(10208.0, 7024.0, DEVICE_GRAPHIRE); break; case 0x16: // Graphire 4 6x8 (tested) - SetDevice(16704.0, 12064.0, DEVICE_GRAPHIRE, 8); + SetDevice(16704.0, 12064.0, DEVICE_GRAPHIRE); break; case 0x20: - SetDevice(12700.0, 10600.0); + SetDevice(12700.0, 10600.0, DEVICE_INTUOS); break; case 0x21: SetDevice(20320.0, 16240.0); @@ -153,25 +150,25 @@ SetDevice(45720.0, 31680.0); break; case 0x30: - SetDevice(5408.0, 4056.0, DEVICE_PL500, 8); + SetDevice(5408.0, 4056.0, DEVICE_PL500); break; case 0x31: - SetDevice(6144.0, 4608.0, DEVICE_PL500, 8); + SetDevice(6144.0, 4608.0, DEVICE_PL500); break; case 0x32: - SetDevice(6126.0, 4604.0, DEVICE_PL500, 8); + SetDevice(6126.0, 4604.0, DEVICE_PL500); break; case 0x33: - SetDevice(6260.0, 5016.0, DEVICE_PL500, 8); + SetDevice(6260.0, 5016.0, DEVICE_PL500); break; case 0x34: - SetDevice(6144.0, 4608.0, DEVICE_PL500, 8); + SetDevice(6144.0, 4608.0, DEVICE_PL500); break; case 0x35: - SetDevice(7220.0, 5780.0, DEVICE_PL500, 8); + SetDevice(7220.0, 5780.0, DEVICE_PL500); break; case 0x3F: - SetDevice(87200.0, 65600.0, DEVICE_CINTIQ, 10); + SetDevice(87200.0, 65600.0, DEVICE_CINTIQ); break; case 0x41: SetDevice(12700.0, 10600.0); @@ -192,30 +189,30 @@ SetDevice(20320.0, 16240.0); break; case 0x60: - SetDevice(5104.0, 3712.0, DEVICE_GRAPHIRE, 8); + SetDevice(5104.0, 3712.0, DEVICE_GRAPHIRE); break; case 0x61: // PenStation -// SetDevice(3403.0, 2475.0, DEVICE_GRAPHIRE, 8); // this version was untested - SetDevice(3248.0, 2320.0, DEVICE_PENSTATION, 8); // this version came from "beer" +// SetDevice(3403.0, 2475.0, DEVICE_GRAPHIRE); // this version was untested + SetDevice(3248.0, 2320.0, DEVICE_PENSTATION); // this version came from "beer" break; case 0x62: // Volito - SetDevice(5040.0, 3712.0, DEVICE_VOLITO, 8); + SetDevice(5040.0, 3712.0, DEVICE_VOLITO); break; case 0x64: // PenPartner.1 -// SetDevice(3450.0, 2100.0, DEVICE_PENSTATION, 8); - SetDevice(3248.0, 2320.0, DEVICE_PENSTATION, 8); +// SetDevice(3450.0, 2100.0, DEVICE_PENSTATION); + SetDevice(3248.0, 2320.0, DEVICE_PENSTATION); break; case 0xB0: - SetDevice(25400.0, 20320.0, DEVICE_INTUOS3, 10); + SetDevice(25400.0, 20320.0, DEVICE_INTUOS3); break; case 0xB1: // tested: - SetDevice(20320.0, 15230.0, DEVICE_INTUOS3, 10); + SetDevice(20320.0, 15230.0, DEVICE_INTUOS3); // Frans: -// SetDevice(40640.0, 30480.0, DEVICE_INTUOS3, 10); +// SetDevice(40640.0, 30480.0, DEVICE_INTUOS3); break; case 0xB2: - SetDevice(60960.0, 45720.0, DEVICE_INTUOS3, 10); + SetDevice(60960.0, 45720.0, DEVICE_INTUOS3); break; default: status = B_BAD_VALUE; @@ -226,19 +223,18 @@ // SetDevice void -TabletDevice::SetDevice(float maxX, float maxY, uint32 mode, int dataBytes) +TabletDevice::SetDevice(float maxX, float maxY, uint32 mode) { fDeviceMode = mode; fMaxX = maxX; fMaxY = maxY; - fDataBytes = dataBytes; fJitterX = JITTER_X; fJitterY = JITTER_Y; } // ReadData void -TabletDevice::ReadData(uchar* data, bool& hasContact, uint32& mode, +TabletDevice::ReadData(const uchar* data, bool& hasContact, uint32& mode, uint32& buttons, float& x, float& y, float& pressure, int32& clicks, int32& eraser, float& wheelX, float& wheelY, float& tiltX, float& tiltY) const @@ -513,7 +509,9 @@ } else if (what == B_MOUSE_UP) event->AddInt32("clicks", 0); - fParent->EnqueueMessage(event); + status_t ret = fParent->EnqueueMessage(event); + if (ret < B_OK) + PRINT(("EnqueueMessage(): %s\n", strerror(ret))); // apply values to members fPosX = x; @@ -555,54 +553,59 @@ TabletDevice* tabletDevice = (TabletDevice*)arg; DeviceReader* reader = tabletDevice->fReader; - if (reader && reader->InitCheck() >= B_OK) { + if (!reader || reader->InitCheck() < B_OK) + return B_BAD_VALUE; - int dataBytes = tabletDevice->DataBytes(); - uchar* data = new uchar[max_c(12, dataBytes)]; + int dataBytes = reader->MaxPacketSize(); + if (dataBytes > 128) + return B_BAD_VALUE; - while (tabletDevice->IsActive()) { + uchar data[max_c(12, dataBytes)]; - status_t ret = reader->ReadData(data, dataBytes); + while (tabletDevice->IsActive()) { - if (ret == dataBytes) { - // data we read from the wacom device - uint32 mode; - bool hasContact = false; - uint32 buttons = 0; - float x = 0.0; - float y = 0.0; - float pressure = 0.0; - int32 clicks = 0; - int32 eraser = 0; - float wheelX = 0.0; - float wheelY = 0.0; - float tiltX = 0.0; - float tiltY = 0.0; - // let the device extract all information from the data - tabletDevice->ReadData(data, hasContact, mode, buttons, - x, y, pressure, clicks, eraser, - wheelX, wheelY, tiltX, tiltY); - if (hasContact) { - // apply the changes to the device - tabletDevice->SetStatus(mode, buttons, x, y, pressure, - clicks, modifiers(), eraser, - wheelX, wheelY, tiltX, tiltY, data); + status_t ret = reader->ReadData(data, dataBytes); + + if (ret == dataBytes) { + // data we read from the wacom device + uint32 mode; + bool hasContact = false; + uint32 buttons = 0; + float x = 0.0; + float y = 0.0; + float pressure = 0.0; + int32 clicks = 0; + int32 eraser = 0; + float wheelX = 0.0; + float wheelY = 0.0; + float tiltX = 0.0; + float tiltY = 0.0; + // let the device extract all information from the data + tabletDevice->ReadData(data, hasContact, mode, buttons, + x, y, pressure, clicks, eraser, + wheelX, wheelY, tiltX, tiltY); + if (hasContact) { + // apply the changes to the device + tabletDevice->SetStatus(mode, buttons, x, y, pressure, + clicks, modifiers(), eraser, + wheelX, wheelY, tiltX, tiltY, data); + } else + PRINT(("device has no contact\n")); + tabletDevice->SetContact(hasContact); + } else { + PRINT(("failed to read %ld bytes, read: %ld or %s\n", + dataBytes, ret, strerror(ret))); + + if (ret < B_OK) { + if (ret == B_TIMED_OUT) + snooze(SNOOZE_AMOUNT); + else if (ret == B_INTERRUPTED) + snooze(SNOOZE_AMOUNT); + else { + return ret; } - tabletDevice->SetContact(hasContact); - } else { - if (ret < B_OK) { - if (ret == B_TIMED_OUT) - snooze(SNOOZE_AMOUNT); - else if (ret == B_INTERRUPTED) - snooze(SNOOZE_AMOUNT); - else { - delete[] data; - return ret; - } - } } } - delete[] data; } return B_OK; Modified: haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.h =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.h 2008-02-19 16:00:11 UTC (rev 24017) +++ haiku/trunk/src/add-ons/input_server/devices/wacom/TabletDevice.h 2008-02-19 16:03:15 UTC (rev 24018) @@ -25,16 +25,12 @@ virtual status_t Start(); virtual status_t Stop(); - inline int DataBytes() const - { return fDataBytes; } + status_t DetectDevice(const DeviceReader* reader); - status_t DetectDevice(uint16 productID); - void SetDevice(float maxX, float maxY, - uint32 mode = DEVICE_INTUOS, - int dataBytes = 10); + uint32 mode = DEVICE_INTUOS); - void ReadData(uchar* data, + void ReadData(const uchar* data, bool& hasContact, uint32& mode, uint32& buttons, From stippi at mail.berlios.de Tue Feb 19 17:06:32 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 19 Feb 2008 17:06:32 +0100 Subject: [Haiku-commits] r24019 - haiku/trunk/src/add-ons/kernel/drivers/input/wacom Message-ID: <200802191606.m1JG6WGo008934@sheep.berlios.de> Author: stippi Date: 2008-02-19 17:06:32 +0100 (Tue, 19 Feb 2008) New Revision: 24019 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24019&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c Log: * Small cleanups, renamed "md" (for "mouse device") to "device" among other stuff. * It's a while since I wrote this code, and I don't remember why I don't always "set the configuration". Appearantly on BeOS and ZETA, the active configuration was not yet set on the device when the driver examined it, but on Haiku it is. The special control command which puts a tablet into tablet mode is then not executed. I simply commented out this check (always set the configuration) and now my Wacom Intuos 2 is working fine in Haiku. Modified: haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c 2008-02-19 16:03:15 UTC (rev 24018) +++ haiku/trunk/src/add-ons/kernel/drivers/input/wacom/wacom.c 2008-02-19 16:06:32 UTC (rev 24019) @@ -33,23 +33,23 @@ typedef struct wacom_device wacom_device; struct wacom_device { - wacom_device* next; + wacom_device* next; - int open; - int number; + int open; + int number; - usb_device dev; + usb_device dev; - usb_pipe pipe; - char* data; - size_t max_packet_size; - size_t length; + usb_pipe pipe; + char* data; + size_t max_packet_size; + size_t length; - uint16 vendor; - uint16 product; + uint16 vendor; + uint16 product; - sem_id notify_lock; - uint32 status; + sem_id notify_lock; + uint32 status; }; // handy strings for referring to ourself @@ -98,14 +98,14 @@ // #pragma mark - Device addition and removal // // add_device() and remove_device() are used to create and tear down -// device instances. They are driver by the callbacks device_added() +// device instances. They are used from the callbacks device_added() // and device_removed() which are invoked by the USB bus manager. // add_device static wacom_device* add_device(usb_device dev) { - wacom_device *md = NULL; + wacom_device *device = NULL; int num, ifc, alt; const usb_interface_info *ii; status_t st; @@ -162,24 +162,23 @@ fail: put_number(num); - if (md) { - if (md->data) - free(md->data); - free(md); + if (device) { + free(device->data); + free(device); } return NULL; got_one: - if ((md = (wacom_device *) malloc(sizeof(wacom_device))) == NULL) + if ((device = (wacom_device *) malloc(sizeof(wacom_device))) == NULL) goto fail; - md->dev = dev; - md->number = num; - md->open = 1; - md->notify_lock = -1; - md->data = NULL; + device->dev = dev; + device->number = num; + device->open = 1; + device->notify_lock = -1; + device->data = NULL; - if (setConfiguration) { +// if (setConfiguration) { // the configuration has to be set yet (was not the current one) DPRINTF_INFO((ID "add_device() - setting configuration...\n")); if ((st = usb->set_configuration(dev, conf)) != B_OK) { @@ -217,70 +216,70 @@ if (st < B_OK) dprintf(ID "add_device() - control transfer 2 failed: %ld\n", st); } - } +// } // configure the rest of the wacom_device - md->pipe = ii->endpoint[0].handle; -//DPRINTF_INFO((ID "add_device() - pipe id = %ld\n", md->pipe)); - md->length = 0; - md->max_packet_size = ii->endpoint[0].descr->max_packet_size; - md->data = (char*)malloc(md->max_packet_size); - if (md->data == NULL) + device->pipe = ii->endpoint[0].handle; +//DPRINTF_INFO((ID "add_device() - pipe id = %ld\n", device->pipe)); + device->length = 0; + device->max_packet_size = ii->endpoint[0].descr->max_packet_size; + device->data = (char*)malloc(device->max_packet_size); + if (device->data == NULL) goto fail; -//DPRINTF_INFO((ID "add_device() - max packet length = %ld\n", md->max_packet_size)); - md->status = 0;//B_USB_STATUS_SUCCESS; - md->vendor = udd->vendor_id; - md->product = udd->product_id; +//DPRINTF_INFO((ID "add_device() - max packet length = %ld\n", device->max_packet_size)); + device->status = 0;//B_USB_STATUS_SUCCESS; + device->vendor = udd->vendor_id; + device->product = udd->product_id; - DPRINTF_INFO((ID "add_device() - added %p (/dev/%s%d)\n", md, kBasePublishPath, num)); + DPRINTF_INFO((ID "add_device() - added %p (/dev/%s%d)\n", device, kBasePublishPath, num)); // add it to the list of devices so it will be published, etc acquire_sem(sDeviceListLock); - md->next = sDeviceList; - sDeviceList = md; + device->next = sDeviceList; + sDeviceList = device; sDeviceCount++; release_sem(sDeviceListLock); - return md; + return device; } // remove_device static void -remove_device(wacom_device *md) +remove_device(wacom_device *device) { - put_number(md->number); + put_number(device->number); - usb->cancel_queued_transfers(md->pipe); + usb->cancel_queued_transfers(device->pipe); - delete_sem(md->notify_lock); - if (md->data) - free(md->data); - free(md); + delete_sem(device->notify_lock); + if (device->data) + free(device->data); + free(device); } // device_added static status_t device_added(usb_device dev, void** cookie) { - wacom_device* md; + wacom_device* device; DPRINTF_INFO((ID "device_added(%ld,...)\n", dev)); // first see, if this device is already added acquire_sem(sDeviceListLock); - for (md = sDeviceList; md; md = md->next) { - DPRINTF_ERR((ID "device_added() - old device: %ld\n", md->dev)); - if (md->dev == dev) { + for (device = sDeviceList; device; device = device->next) { + DPRINTF_ERR((ID "device_added() - old device: %ld\n", device->dev)); + if (device->dev == dev) { DPRINTF_ERR((ID "device_added() - already added - done!\n")); - *cookie = (void*)md; + *cookie = (void*)device; release_sem(sDeviceListLock); return B_OK; } } release_sem(sDeviceListLock); - if ((md = add_device(dev)) != NULL) { - *cookie = (void*)md; + if ((device = add_device(dev)) != NULL) { + *cookie = (void*)device; DPRINTF_INFO((ID "device_added() - done!\n")); return B_OK; } else @@ -293,22 +292,22 @@ static status_t device_removed(void *cookie) { - wacom_device *md = (wacom_device *) cookie; + wacom_device *device = (wacom_device *) cookie; - DPRINTF_INFO((ID "device_removed(%p)\n", md)); + DPRINTF_INFO((ID "device_removed(%p)\n", device)); - if (md) { + if (device) { acquire_sem(sDeviceListLock); // remove it from the list of devices - if (md == sDeviceList) { - sDeviceList = md->next; + if (device == sDeviceList) { + sDeviceList = device->next; } else { wacom_device *n; for (n = sDeviceList; n; n = n->next) { - if (n->next == md) { - n->next = md->next; + if (n->next == device) { + n->next = device->next; break; } } @@ -318,15 +317,15 @@ // tear it down if it's not open -- // otherwise the last device_free() will handle it - md->open--; + device->open--; - DPRINTF_ERR((ID "device_removed() open: %d\n", md->open)); + DPRINTF_ERR((ID "device_removed() open: %d\n", device->open)); - if (md->open == 0) { - remove_device(md); + if (device->open == 0) { + remove_device(device); } else { dprintf(ID "device /dev/%s%d still open -- marked for removal\n", - kBasePublishPath, md->number); + kBasePublishPath, device->number); } release_sem(sDeviceListLock); @@ -343,7 +342,7 @@ static status_t device_open(const char *dname, uint32 flags, void **cookie) { - wacom_device *md; + wacom_device *device; int n; status_t ret = B_ERROR; @@ -359,17 +358,17 @@ DPRINTF_INFO((ID "device_open(\"%s\",%d,...)\n", dname, flags)); acquire_sem(sDeviceListLock); - for (md = sDeviceList; md; md = md->next) { - if (md->number == n) { -// if (md->open <= 1) { - md->open++; - *cookie = md; - DPRINTF_ERR((ID "device_open() open: %d\n", md->open)); + for (device = sDeviceList; device; device = device->next) { + if (device->number == n) { +// if (device->open <= 1) { + device->open++; + *cookie = device; + DPRINTF_ERR((ID "device_open() open: %d\n", device->open)); - if (md->notify_lock < 0) { - if ((md->notify_lock = create_sem(0, "notify_lock")) < 0) { - ret = md->notify_lock; - md->open--; + if (device->notify_lock < 0) { + if ((device->notify_lock = create_sem(0, "notify_lock")) < 0) { + ret = device->notify_lock; + device->open--; *cookie = NULL; dprintf(ID "device_open() -> create_sem() returns %ld\n", ret); } else { @@ -394,8 +393,8 @@ device_close (void *cookie) { #if DEBUG_DRIVER - wacom_device *md = (wacom_device*) cookie; - DPRINTF_ERR((ID "device_close() name = \"%s%d\"\n", kBasePublishPath, md->number)); + wacom_device *device = (wacom_device*) cookie; + DPRINTF_ERR((ID "device_close() name = \"%s%d\"\n", kBasePublishPath, device->number)); #endif return B_OK; } @@ -404,18 +403,18 @@ static status_t device_free(void *cookie) { - wacom_device *md = (wacom_device *)cookie; + wacom_device *device = (wacom_device *)cookie; - DPRINTF_INFO((ID "device_free() name = \"%s%d\"\n", kBasePublishPath, md->number)); + DPRINTF_INFO((ID "device_free() name = \"%s%d\"\n", kBasePublishPath, device->number)); acquire_sem(sDeviceListLock); - md->open--; + device->open--; - DPRINTF_INFO((ID "device_free() open: %ld\n", md->open)); + DPRINTF_INFO((ID "device_free() open: %ld\n", device->open)); - if (md->open == 0) { - remove_device(md); + if (device->open == 0) { + remove_device(device); } release_sem(sDeviceListLock); @@ -425,24 +424,24 @@ // device_interupt_callback static void device_interupt_callback(void* cookie, uint32 status, - void* data, uint32 actual_len) + void* data, uint32 actualLength) { - wacom_device* md = (wacom_device*)cookie; - uint32 length = min_c(actual_len, md->max_packet_size); + wacom_device* device = (wacom_device*)cookie; + uint32 length = min_c(actualLength, device->max_packet_size); DPRINTF_INFO((ID "device_interupt_callback(%p) name = \"%s%d\" -> " - "status: %ld, length: %ld\n", cookie, kBasePublishPath, md->number, - status, actual_len)); + "status: %ld, length: %ld\n", cookie, kBasePublishPath, device->number, + status, actualLength)); - md->status = status; - if (md->notify_lock >= 0) { + device->status = status; + if (device->notify_lock >= 0) { if (status == 0/*B_USB_STATUS_SUCCESS*/) { - memcpy(md->data, data, length); - md->length = length; + memcpy(device->data, data, length); + device->length = length; } else { - md->length = 0; + device->length = 0; } - release_sem(md->notify_lock); + release_sem(device->notify_lock); } DPRINTF_INFO((ID "device_interupt_callback() - done\n")); @@ -450,32 +449,32 @@ // read_header static void -read_header(const wacom_device* md, void* buffer) +read_header(const wacom_device* device, void* buffer) { uint16* ids = (uint16*)buffer; uint32* size = (uint32*)buffer; - ids[0] = md->vendor; - ids[1] = md->product; - size[1] = md->max_packet_size; + ids[0] = device->vendor; + ids[1] = device->product; + size[1] = device->max_packet_size; } // device_read static status_t device_read(void* cookie, off_t pos, void* buf, size_t* count) { - wacom_device* md = (wacom_device*) cookie; + wacom_device* device = (wacom_device*) cookie; status_t ret = B_BAD_VALUE; uint8* buffer = (uint8*)buf; uint32 dataLength; - if (!md) + if (!device) return ret; - ret = md->notify_lock; + ret = device->notify_lock; DPRINTF_INFO((ID "device_read(%p,%Ld,0x%x,%d) name = \"%s%d\"\n", - cookie, pos, buf, *count, kBasePublishPath, md->number)); + cookie, pos, buf, *count, kBasePublishPath, device->number)); if (ret >= B_OK) { // what the client "reads" is decided depending on how much bytes are provided @@ -484,53 +483,53 @@ // is scheduled, and an error report is returned as appropriate if (*count > 8) { // queue the interrupt transfer - ret = usb->queue_interrupt(md->pipe, md->data, md->max_packet_size, - device_interupt_callback, md); + ret = usb->queue_interrupt(device->pipe, device->data, device->max_packet_size, + device_interupt_callback, device); if (ret >= B_OK) { // we will block here until the interrupt transfer has been done - ret = acquire_sem_etc(md->notify_lock, 1, B_RELATIVE_TIMEOUT, 500 * 1000); + ret = acquire_sem_etc(device->notify_lock, 1, B_RELATIVE_TIMEOUT, 500 * 1000); // handle time out if (ret < B_OK) { -// usb->cancel_queued_transfers(md->pipe); +// usb->cancel_queued_transfers(device->pipe); if (ret == B_TIMED_OUT) { // a time_out is ok, since it only means that the device // had nothing to report (ie mouse/pen was not moved) within // the given time interval DPRINTF_INFO((ID "device_read(%p) name = \"%s%d\" -> " - "B_TIMED_OUT\n", cookie, kBasePublishPath, md->number)); + "B_TIMED_OUT\n", cookie, kBasePublishPath, device->number)); *count = 8; - read_header(md, buffer); + read_header(device, buffer); ret = B_OK; } else { // any other error trying to acquire the semaphore *count = 0; } } else { - if (md->status == 0/*B_USBD_SUCCESS*/) { + if (device->status == 0/*B_USBD_SUCCESS*/) { DPRINTF_INFO((ID "interrupt transfer - success\n")); // copy the data from the buffer - dataLength = min_c(md->length, *count - 8); + dataLength = min_c(device->length, *count - 8); *count = dataLength + 8; - read_header(md, buffer); - memcpy(buffer + 8, md->data, dataLength); + read_header(device, buffer); + memcpy(buffer + 8, device->data, dataLength); } else { // an error happened during the interrupt transfer *count = 0; - dprintf(ID "interrupt transfer - failure: %ld\n", md->status); + dprintf(ID "interrupt transfer - failure: %ld\n", device->status); ret = B_ERROR; } } } else { *count = 0; dprintf(ID "device_read(%p) name = \"%s%d\" -> error queuing interrupt: %ld\n", - cookie, kBasePublishPath, md->number, ret); + cookie, kBasePublishPath, device->number, ret); } } else if (*count == 8) { - read_header(md, buffer); + read_header(device, buffer); ret = B_OK; } else { dprintf(ID "device_read(%p) name = \"%s%d\" -> buffer size must be at least 8 bytes!\n", - cookie, kBasePublishPath, md->number); + cookie, kBasePublishPath, device->number); *count = 0; ret = B_BAD_VALUE; } @@ -634,7 +633,7 @@ const char** publish_devices() { - wacom_device *md; + wacom_device *device; int i; DPRINTF_INFO((ID "publish_devices()\n")); @@ -648,9 +647,9 @@ acquire_sem(sDeviceListLock); sDeviceNames = (char **) malloc(sizeof(char*) * (sDeviceCount + 2)); if (sDeviceNames) { - for (i = 0, md = sDeviceList; md; md = md->next) { + for (i = 0, device = sDeviceList; device; device = device->next) { if ((sDeviceNames[i] = (char *) malloc(strlen(kBasePublishPath) + 4))) { - sprintf(sDeviceNames[i],"%s%d",kBasePublishPath,md->number); + sprintf(sDeviceNames[i],"%s%d",kBasePublishPath,device->number); DPRINTF_INFO((ID "publishing: \"/dev/%s\"\n",sDeviceNames[i])); i++; } From axeld at pinc-software.de Tue Feb 19 17:49:18 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 19 Feb 2008 17:49:18 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r24015_-_in_haiku/trunk=3A_build/?= =?iso-8859-15?q?jam_src/preferences/keymap?= In-Reply-To: <47BAEAF8.5050000@zappotek.com> Message-ID: <24063626191-BeMail@zon> Alexandre Deckner wrote: > Ohh, pretty! Will do! > What about those: > http://haiku.it.su.se:8180/source/search?n=25&start=0&refs=create_directory > > :-O Feel free to change those, too, hehe :-) (only when you're bored, of course) Bye, Axel. From axeld at pinc-software.de Tue Feb 19 17:54:00 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 19 Feb 2008 17:54:00 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23939_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel_src/system/kernel__src/system/kernel/vm?= In-Reply-To: Message-ID: <24345084458-BeMail@zon> "J?r?me Duval" wrote: > 2008/2/19, Axel D?rfler : > > > Even though the current slab has functionality to manage memory > > > without > > > depending on areas it would probably need some work the get it > > > going > > > as a heap > > > replacement that performs as efficient. > > It definitely needs some work, yes. I still think it's worth it, > > though > > :-) > To clear my mind, the modified heap allocator is the one only for the > kernel, no ? Is there another one for userland ? Only for the kernel, yes. The userland allocator lives in src/system/ libroot/posix/malloc/. When I said "only one allocator" I only meant the kernel. Even though it might be possible to join userland and kernel allocators as well in the future, I wouldn't pursue this for now. Bye, Axel. From axeld at mail.berlios.de Tue Feb 19 20:16:37 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 19 Feb 2008 20:16:37 +0100 Subject: [Haiku-commits] r24020 - haiku/trunk/src/system/kernel/fs Message-ID: <200802191916.m1JJGbNW011928@sheep.berlios.de> Author: axeld Date: 2008-02-19 20:16:36 +0100 (Tue, 19 Feb 2008) New Revision: 24020 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24020&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Improved (and tested) the advisory file locking mechanism a bit: * our flock::l_len was inclusive, while it's exclusive (the last byte locked is (l_start - 1 + l_len) not just (l_start + l_len). * F_UNLCK removes all locks of the calling process that are within the specified region - existing locks might also cut or divided. * Apparently, a single team can lock the same region as often as it wants. * advisory_locking is now using a DoublyLinkedList instead of its C counterpart. * advisory_lock now has start + end fields, instead of offset + len, it's handier this way. * This fixes bug #1791. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-19 16:06:32 UTC (rev 24019) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-02-19 19:16:36 UTC (rev 24020) @@ -121,21 +121,23 @@ bool owns_file_device; }; -struct advisory_locking { - sem_id lock; - sem_id wait_sem; - struct list locks; -}; - -struct advisory_lock { +struct advisory_lock : public DoublyLinkedListLinkImpl { list_link link; team_id team; pid_t session; - off_t offset; - off_t length; + off_t start; + off_t end; bool shared; }; +typedef DoublyLinkedList LockList; + +struct advisory_locking { + sem_id lock; + sem_id wait_sem; + LockList locks; +}; + static mutex sFileSystemsMutex; /*! \brief Guards sMountsTable. @@ -1047,8 +1049,7 @@ if (vnode == NULL) return B_FILE_ERROR; - struct advisory_locking *locking = (struct advisory_locking *)malloc( - sizeof(struct advisory_locking)); + struct advisory_locking *locking = new(std::nothrow) advisory_locking; if (locking == NULL) return B_NO_MEMORY; @@ -1066,13 +1067,11 @@ goto err2; } - list_init(&locking->locks); - // We need to set the locking structure atomically - someone // else might set one at the same time do { - if (atomic_test_and_set((vint32 *)&vnode->advisory_locking, (addr_t)locking, - NULL) == NULL) + if (atomic_test_and_set((vint32 *)&vnode->advisory_locking, + (addr_t)locking, NULL) == NULL) return B_OK; } while (get_advisory_locking(vnode) == NULL); @@ -1084,7 +1083,7 @@ err2: delete_sem(locking->wait_sem); err1: - free(locking); + delete locking; return status; } @@ -1102,11 +1101,13 @@ team_id team = team_get_current_team_id(); status_t status = B_BAD_VALUE; - struct advisory_lock *lock = NULL; - while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, lock)) != NULL) { + LockList::Iterator iterator = locking->locks.GetIterator(); + while (iterator.HasNext()) { + struct advisory_lock *lock = iterator.Next(); + if (lock->team == team) { - flock->l_start = lock->offset; - flock->l_len = lock->length; + flock->l_start = lock->start; + flock->l_len = lock->end - lock->start + 1; status = B_OK; break; } @@ -1117,6 +1118,20 @@ } +/*! Returns \c true when either \a flock is \c NULL or the \a flock intersects + with the advisory_lock \a lock. +*/ +static bool +advisory_lock_intersects(struct advisory_lock *lock, struct flock *flock) +{ + if (flock == NULL) + return true; + + return lock->start <= flock->l_start - 1 + flock->l_len + && lock->end >= flock->l_start; +} + + /*! Removes the specified lock, or all locks of the calling team if \a flock is NULL. */ @@ -1127,49 +1142,87 @@ struct advisory_locking *locking = get_advisory_locking(vnode); if (locking == NULL) - return flock != NULL ? B_BAD_VALUE : B_OK; + return B_OK; + // TODO: use the thread ID instead?? team_id team = team_get_current_team_id(); pid_t session = thread_get_current_thread()->team->session_id; - // find matching lock entry + // find matching lock entries - status_t status = B_BAD_VALUE; - struct advisory_lock *lock = NULL; - while ((lock = (struct advisory_lock *)list_get_next_item(&locking->locks, - lock)) != NULL) { - if (lock->team == team && (flock == NULL - || (flock != NULL && lock->offset == flock->l_start - && lock->length == flock->l_len)) - || lock->session == session) { - // we found our lock, free it - list_remove_item(&locking->locks, lock); + LockList::Iterator iterator = locking->locks.GetIterator(); + while (iterator.HasNext()) { + struct advisory_lock *lock = iterator.Next(); + bool removeLock = false; + + if (lock->session == session) + removeLock = true; + else if (lock->team == team && advisory_lock_intersects(lock, flock)) { + bool endsBeyond = false; + bool startsBefore = false; + if (flock != NULL) { + startsBefore = lock->start < flock->l_start; + endsBeyond = lock->end > flock->l_start - 1 + flock->l_len; + } + + if (!startsBefore && !endsBeyond) { + // lock is completely contained in flock + removeLock = true; + } else if (startsBefore && !endsBeyond) { + // cut the end of the lock + lock->end = flock->l_start - 1; + } else if (!startsBefore && endsBeyond) { + // cut the start of the lock + lock->start = flock->l_start + flock->l_len; + } else { + // divide the lock into two locks + struct advisory_lock *secondLock = new advisory_lock; + if (secondLock == NULL) { + // TODO: we should probably revert the locks we already + // changed... (ie. allocate upfront) + put_advisory_locking(locking); + return B_NO_MEMORY; + } + + lock->end = flock->l_start - 1; + + secondLock->team = lock->team; + secondLock->session = lock->session; + // values must already be normalized when getting here + secondLock->start = flock->l_start + flock->l_len; + secondLock->end = lock->end; + secondLock->shared = lock->shared; + + locking->locks.Add(secondLock); + } + } + + if (removeLock) { + // this lock is no longer used + iterator.Remove(); free(lock); - status = B_OK; - break; } } - bool removeLocking = list_is_empty(&locking->locks); + bool removeLocking = locking->locks.IsEmpty(); release_sem_etc(locking->wait_sem, 1, B_RELEASE_ALL); put_advisory_locking(locking); - if (status < B_OK) - return status; - if (removeLocking) { - // we can remove the whole advisory locking structure; it's no longer used + // We can remove the whole advisory locking structure; it's no + // longer used locking = get_advisory_locking(vnode); if (locking != NULL) { // the locking could have been changed in the mean time - if (list_is_empty(&locking->locks)) { + if (locking->locks.IsEmpty()) { vnode->advisory_locking = NULL; - // we've detached the locking from the vnode, so we can safely delete it + // we've detached the locking from the vnode, so we can + // safely delete it delete_sem(locking->lock); delete_sem(locking->wait_sem); - free(locking); + delete locking; } else { // the locking is in use again release_sem_etc(locking->lock, 1, B_DO_NOT_RESCHEDULE); @@ -1206,15 +1259,17 @@ // if this vnode has an advisory_locking structure attached, // lock that one and search for any colliding file lock struct advisory_locking *locking = get_advisory_locking(vnode); + team_id team = team_get_current_team_id(); sem_id waitForLock = -1; if (locking != NULL) { // test for collisions - struct advisory_lock *lock = NULL; - while ((lock = (struct advisory_lock *)list_get_next_item( - &locking->locks, lock)) != NULL) { - if (lock->offset <= flock->l_start + flock->l_len - && lock->offset + lock->length > flock->l_start) { + LockList::Iterator iterator = locking->locks.GetIterator(); + while (iterator.HasNext()) { + struct advisory_lock *lock = iterator.Next(); + + // TODO: locks from the same team might be joinable! + if (lock->team != team && advisory_lock_intersects(lock, flock)) { // locks do overlap if (!shared || !lock->shared) { // we need to wait @@ -1271,11 +1326,11 @@ lock->team = team_get_current_team_id(); lock->session = session; // values must already be normalized when getting here - lock->offset = flock->l_start; - lock->length = flock->l_len; + lock->start = flock->l_start; + lock->end = flock->l_start - 1 + flock->l_len; lock->shared = shared; - list_add_item(&locking->locks, lock); + locking->locks.Add(lock); put_advisory_locking(locking); return status; @@ -2367,12 +2422,14 @@ kprintf(" lock: %ld", locking->lock); kprintf(" wait_sem: %ld", locking->wait_sem); - struct advisory_lock *lock = NULL; int32 index = 0; - while ((lock = (advisory_lock *)list_get_next_item(&locking->locks, lock)) != NULL) { - kprintf(" [%2ld] team: %ld\n", index, lock->team); - kprintf(" offset: %Ld\n", lock->offset); - kprintf(" length: %Ld\n", lock->length); + LockList::Iterator iterator = locking->locks.GetIterator(); + while (iterator.HasNext()) { + struct advisory_lock *lock = iterator.Next(); + + kprintf(" [%2ld] team: %ld\n", index++, lock->team); + kprintf(" start: %Ld\n", lock->start); + kprintf(" end: %Ld\n", lock->end); kprintf(" shared? %s\n", lock->shared ? "yes" : "no"); } } From kirilla at mail.berlios.de Tue Feb 19 23:08:54 2008 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Tue, 19 Feb 2008 23:08:54 +0100 Subject: [Haiku-commits] r24021 - haiku/trunk/src/apps/mail Message-ID: <200802192208.m1JM8slB004362@sheep.berlios.de> Author: kirilla Date: 2008-02-19 23:08:54 +0100 (Tue, 19 Feb 2008) New Revision: 24021 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24021&view=rev Modified: haiku/trunk/src/apps/mail/MailApp.cpp haiku/trunk/src/apps/mail/MailWindow.cpp haiku/trunk/src/apps/mail/Messages.h Log: Added an Accounts menu item which opens the E-mail preferences. Modified: haiku/trunk/src/apps/mail/MailApp.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailApp.cpp 2008-02-19 19:16:36 UTC (rev 24020) +++ haiku/trunk/src/apps/mail/MailApp.cpp 2008-02-19 22:08:54 UTC (rev 24021) @@ -374,6 +374,10 @@ break; } + case M_ACCOUNTS: + be_roster->Launch("application/x-vnd.Haiku-Mail"); + break; + case M_EDIT_SIGNATURE: if (fSigWindow) fSigWindow->Activate(true); Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-19 19:16:36 UTC (rev 24020) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-19 22:08:54 UTC (rev 24021) @@ -354,6 +354,10 @@ new BMessage(M_PREFS),',')); item->SetTarget(be_app); menu_bar->AddItem(menu); + menu->AddItem(item = new BMenuItem( + MDR_DIALECT_CHOICE ("Accounts","Accounts") B_UTF8_ELLIPSIS, + new BMessage(M_ACCOUNTS),'-')); + item->SetTarget(be_app); // // View Menu Modified: haiku/trunk/src/apps/mail/Messages.h =================================================================== --- haiku/trunk/src/apps/mail/Messages.h 2008-02-19 19:16:36 UTC (rev 24020) +++ haiku/trunk/src/apps/mail/Messages.h 2008-02-19 22:08:54 UTC (rev 24021) @@ -100,6 +100,7 @@ M_SIG_MENU, M_FIND, M_FIND_AGAIN, + M_ACCOUNTS, // queries M_EDIT_QUERIES, From kirilla at mail.berlios.de Tue Feb 19 23:13:48 2008 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Tue, 19 Feb 2008 23:13:48 +0100 Subject: [Haiku-commits] r24022 - haiku/trunk/src/apps/mail Message-ID: <200802192213.m1JMDm0r005374@sheep.berlios.de> Author: kirilla Date: 2008-02-19 23:13:47 +0100 (Tue, 19 Feb 2008) New Revision: 24022 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24022&view=rev Modified: haiku/trunk/src/apps/mail/MailWindow.cpp Log: Some rephrasing of help message. Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-19 22:08:54 UTC (rev 24021) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2008-02-19 22:13:47 UTC (rev 24022) @@ -1550,8 +1550,8 @@ // just some patience before Tracker pops up the folder snooze(250000); BAlert* alert = new BAlert("helpful message", - "Place your favorite e-mail queries into your " - "this folder. These may also be templates.", + "Put your favorite e-mail queries and query " + "templates in this folder.", "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_IDEA_ALERT); alert->Go(NULL); } From kirilla at mail.berlios.de Wed Feb 20 00:59:09 2008 From: kirilla at mail.berlios.de (kirilla at BerliOS) Date: Wed, 20 Feb 2008 00:59:09 +0100 Subject: [Haiku-commits] r24023 - haiku/trunk/src/bin Message-ID: <200802192359.m1JNx9sU031219@sheep.berlios.de> Author: kirilla Date: 2008-02-20 00:59:07 +0100 (Wed, 20 Feb 2008) New Revision: 24023 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24023&view=rev Modified: haiku/trunk/src/bin/ps.c Log: Added error checking of the return value of get_sem_info(). Modified: haiku/trunk/src/bin/ps.c =================================================================== --- haiku/trunk/src/bin/ps.c 2008-02-19 22:13:47 UTC (rev 24022) +++ haiku/trunk/src/bin/ps.c 2008-02-19 23:59:07 UTC (rev 24023) @@ -21,7 +21,6 @@ int main(int argc, char **argv) { - status_t ret; team_info teaminfo; thread_info thinfo; uint32 teamcookie = 0; @@ -36,7 +35,7 @@ puts(""); puts(PS_HEADER); puts(PS_SEP); - while ((ret = get_next_team_info(&teamcookie, &teaminfo)) >= B_OK) { + while (get_next_team_info(&teamcookie, &teaminfo) >= B_OK) { if (string_to_match) { char *p; p = teaminfo.args; @@ -50,15 +49,18 @@ } printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); thcookie = 0; - while ((ret = get_next_thread_info(teaminfo.team, &thcookie, &thinfo)) >= B_OK) { + while (get_next_thread_info(teaminfo.team, &thcookie, &thinfo) >= B_OK) { if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING) thstate = "???"; else thstate = states[thinfo.state-1]; printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); if (thinfo.state == B_THREAD_WAITING) { - get_sem_info(thinfo.sem, &sinfo); - printf("%s(%ld)\n", sinfo.name, sinfo.sem); + status_t err = get_sem_info(thinfo.sem, &sinfo); + if (!err) + printf("%s(%ld)\n", sinfo.name, sinfo.sem); + else + printf("%s(%ld)\n", strerror(err), thinfo.sem); } else puts(""); } From stippi at mail.berlios.de Wed Feb 20 01:37:40 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 01:37:40 +0100 Subject: [Haiku-commits] r24024 - haiku/trunk/src/kits/interface Message-ID: <200802200037.m1K0bevp011793@sheep.berlios.de> Author: stippi Date: 2008-02-20 01:37:40 +0100 (Wed, 20 Feb 2008) New Revision: 24024 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24024&view=rev Modified: haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp Log: Disable excessive debug output. Modified: haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp =================================================================== --- haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp 2008-02-19 23:59:07 UTC (rev 24023) +++ haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp 2008-02-20 00:37:40 UTC (rev 24024) @@ -46,6 +46,7 @@ // TODO: Check for memory leaks! +//#define DEBUG_LAYOUT // CompoundLayouter class BTwoDimensionalLayout::CompoundLayouter { @@ -342,8 +343,10 @@ // layout the horizontal/vertical elements BSize size = SubtractInsets(View()->Frame().Size()); +#ifdef DEBUG_LAYOUT printf("BTwoDimensionalLayout::LayoutView(%p): size: (%.1f, %.1f)\n", View(), size.width, size.height); +#endif fLocalLayouter->Layout(size); @@ -360,8 +363,10 @@ frame.right += fLeftInset; frame.bottom += fTopInset; { +#ifdef DEBUG_LAYOUT printf(" frame for item %2d (view: %p): ", i, item->View()); frame.PrintToStream(); +#endif //BSize min(item->MinSize()); //BSize max(item->MaxSize()); //printf(" min: (%.1f, %.1f), max: (%.1f, %.1f)\n", min.width, min.height, From mmlr at mail.berlios.de Wed Feb 20 01:40:08 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 20 Feb 2008 01:40:08 +0100 Subject: [Haiku-commits] r24025 - in haiku/trunk: build/jam src/add-ons/kernel/debugger src/add-ons/kernel/debugger/invalidate_on_exit src/servers/app Message-ID: <200802200040.m1K0e8aM012105@sheep.berlios.de> Author: mmlr Date: 2008-02-20 01:40:07 +0100 (Wed, 20 Feb 2008) New Revision: 24025 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24025&view=rev Added: haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/ haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/Jamfile haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/servers/app/Desktop.cpp Log: Implemented a small kernel debugger add-on that triggers a redraw of the entire screen when exiting the kernel debugger. It sets up a thread that sends a message to the (currently hardcoded) desktop message looper. The desktop then does mark the whole screen dirty which causes a full redraw. Since interrupts need to be enabled I went with an asynchronous thread and releasing a request sem in the add-ons' exit hook. Added the add-on to the image as it shouldn't hurt to have it for now. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-20 00:37:40 UTC (rev 24024) +++ haiku/trunk/build/jam/HaikuImage 2008-02-20 00:40:07 UTC (rev 24025) @@ -145,7 +145,8 @@ AddFilesToHaikuImage beos system add-ons kernel busses usb : uhci ehci ; AddFilesToHaikuImage beos system add-ons kernel console : vga_text ; -AddFilesToHaikuImage beos system add-ons kernel debugger : hangman ; +AddFilesToHaikuImage beos system add-ons kernel debugger + : hangman invalidate_on_exit ; AddFilesToHaikuImage beos system add-ons kernel file_systems : $(BEOS_ADD_ONS_FILE_SYSTEMS) ; AddFilesToHaikuImage beos system add-ons kernel generic Added: haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/Jamfile 2008-02-20 00:37:40 UTC (rev 24024) +++ haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/Jamfile 2008-02-20 00:40:07 UTC (rev 24025) @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src add-ons kernel debugger invalidate_on_exit ; + +UsePrivateHeaders kernel ; + +KernelAddon invalidate_on_exit : + invalidate_on_exit.cpp + ; Added: haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp 2008-02-20 00:37:40 UTC (rev 24024) +++ haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp 2008-02-20 00:40:07 UTC (rev 24025) @@ -0,0 +1,80 @@ +/* + * Copyright 2008, Michael Lotz, mmlr at mlotz.ch + * Distributed under the terms of the MIT License. + */ +#include +#include + + +static sem_id sRequestSem = -1; + + +static int32 +invalidate_loop(void *data) +{ + while (true) { + if (acquire_sem(sRequestSem) != B_OK) + break; + + uint32 message[3]; + message[0] = sizeof(message); // size + message[1] = 'KDLE'; // message code + message[2] = 0; // flags + + // where "d:0:baron' stands for desktop x of user y which both + // currently are hardcoded and where '_PTL' is the port link code + write_port(find_port("d:0:baron"), '_PTL', &message, sizeof(message)); + } + + return 0; +} + + +static void +exit_debugger() +{ + release_sem_etc(sRequestSem, 1, B_DO_NOT_RESCHEDULE); +} + + +static status_t +std_ops(int32 op, ...) +{ + if (op == B_MODULE_INIT) { + sRequestSem = create_sem(0, "invalidate_loop_request"); + if (sRequestSem < B_OK) + return sRequestSem; + + thread_id thread = spawn_kernel_thread(&invalidate_loop, + "invalidate_loop", B_NORMAL_PRIORITY, NULL); + if (thread < B_OK) + return thread; + + send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); + return B_OK; + } else if (op == B_MODULE_UNINIT) { + // deleting the sem will also cause the thread to exit + delete_sem(sRequestSem); + sRequestSem = -1; + return B_OK; + } + + return B_BAD_VALUE; +} + + +static struct debugger_module_info sModuleInfo = { + { + "debugger/invalidate_on_exit/v1", + B_KEEP_LOADED, + &std_ops + }, + + NULL, + exit_debugger +}; + +module_info *modules[] = { + (module_info *)&sModuleInfo, + NULL +}; Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2008-02-20 00:37:40 UTC (rev 24024) +++ haiku/trunk/src/servers/app/Desktop.cpp 2008-02-20 00:40:07 UTC (rev 24025) @@ -633,6 +633,17 @@ break; } + // ToDo: Remove this again. It is a message sent by the + // invalidate_on_exit kernel debugger add-on to trigger a redraw + // after exiting a kernel debugger session. + case 'KDLE': + { + BRegion dirty; + dirty.Include(fVirtualScreen.Frame()); + MarkDirty(dirty); + break; + } + default: printf("Desktop %d:%s received unexpected code %ld\n", 0, "baron", code); From stippi at mail.berlios.de Wed Feb 20 01:40:54 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 01:40:54 +0100 Subject: [Haiku-commits] r24026 - haiku/trunk/src/kits/interface Message-ID: <200802200040.m1K0esX2012140@sheep.berlios.de> Author: stippi Date: 2008-02-20 01:40:53 +0100 (Wed, 20 Feb 2008) New Revision: 24026 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24026&view=rev Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp Log: * Looking at the diff I remember it contains a patch Andrea Anzani send me, fixes indicating the focus of the resized column if it isn't the first one. * Code cleanups by myself in the archiving implementation. No functional change. Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-20 00:40:07 UTC (rev 24025) +++ haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-20 00:40:53 UTC (rev 24026) @@ -1514,79 +1514,51 @@ { msg->MakeEmpty(); - // Damn compiler issuing l43m incorrect warnings. - int i; - for (i = 0; ;i++) - { - BColumn *col = (BColumn*) fColumns.ItemAt(i); - if(!col) - break; + for (int32 i = 0; BColumn *col = (BColumn*)fColumns.ItemAt(i); i++) { msg->AddInt32("ID",col->fFieldID); - msg->AddFloat("width",col->fWidth); - msg->AddBool("visible",col->fVisible); + msg->AddFloat("width", col->fWidth); + msg->AddBool("visible", col->fVisible); } - msg->AddBool("sortingenabled",fSortingEnabled); + msg->AddBool("sortingenabled", fSortingEnabled); - if(fSortingEnabled) - { - for (i = 0; ;i++) - { - BColumn *col = (BColumn*) fSortColumns.ItemAt(i); - if(!col) - break; - msg->AddInt32("sortID",col->fFieldID); - msg->AddBool("sortascending",col->fSortAscending); + if (fSortingEnabled) { + for (int32 i = 0; BColumn *col = (BColumn*)fSortColumns.ItemAt(i); + i++) { + msg->AddInt32("sortID", col->fFieldID); + msg->AddBool("sortascending", col->fSortAscending); } } } void BColumnListView::LoadState(BMessage *msg) { - for(int i=0;;i++) - { - int32 ID; - if(B_OK!=msg->FindInt32("ID",i,&ID)) - break; - for(int j=0;;j++) - { - BColumn *col = (BColumn*) fColumns.ItemAt(j); - if(!col) - break; - if(col->fFieldID==ID) - { + int32 id; + for (int i = 0; msg->FindInt32("ID", i, &id) == B_OK; i++) { + for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j); j++) { + if (column->fFieldID == id) { // move this column to position 'i' and set its attributes - MoveColumn(col,i); - float f; - if(B_OK==msg->FindFloat("width",i,&f)) - col->SetWidth(f); - bool b; - if(B_OK==msg->FindBool("visible",i,&b)) - col->SetVisible(b); + MoveColumn(column, i); + float width; + if (msg->FindFloat("width", i, &width) == B_OK) + column->SetWidth(width); + bool visible; + if (msg->FindBool("visible", i, &visible) == B_OK) + column->SetVisible(visible); } } } bool b; - if(B_OK==msg->FindBool("sortingenabled",&b)) - { + if (msg->FindBool("sortingenabled", &b) == B_OK) { SetSortingEnabled(b); - // Damn compiler issuing l43m incorrect warnings. - for(int k=0;;k++) - { - int32 ID; - if(B_OK!=msg->FindInt32("sortID", k, &ID)) - break; - for(int j=0;;j++) - { - BColumn *col = (BColumn*) fColumns.ItemAt(j); - if(!col) - break; - if(col->fFieldID==ID) - { + for (int k = 0; msg->FindInt32("sortID", k, &id) == B_OK; k++) { + for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j); + j++) { + if (column->fFieldID == id) { // add this column to the sort list - bool val; - if(B_OK==msg->FindBool("sortascending", k, &val)) - SetSortColumn(col, true, val); + bool value; + if (msg->FindBool("sortascending", k, &value) == B_OK) + SetSortColumn(column, true, value); } } } @@ -2616,7 +2588,7 @@ if (fFocusRow == row) { if(!fEditMode) { - SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); + fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); fDrawBufferView->StrokeRect(BRect(-1, sourceRect.top, 10000.0, sourceRect.bottom - 1)); } } From stippi at mail.berlios.de Wed Feb 20 01:42:10 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 01:42:10 +0100 Subject: [Haiku-commits] r24027 - haiku/trunk/src/kits/interface Message-ID: <200802200042.m1K0gAUK012207@sheep.berlios.de> Author: stippi Date: 2008-02-20 01:42:09 +0100 (Wed, 20 Feb 2008) New Revision: 24027 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24027&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: I was just going to implement Begin/EndViewTransaction(), but I saw it is already implemented they way I thought it could be done - nice! Just some simplifications. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-02-20 00:40:53 UTC (rev 24026) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-02-20 00:42:09 UTC (rev 24027) @@ -637,12 +637,7 @@ BWindow::BeginViewTransaction() { if (Lock()) { - if (fInTransaction) { - Unlock(); - return; - } fInTransaction = true; - Unlock(); } } @@ -652,13 +647,9 @@ BWindow::EndViewTransaction() { if (Lock()) { - if (!fInTransaction) { - Unlock(); - return; - } - fLink->Flush(); + if (fInTransaction) + fLink->Flush(); fInTransaction = false; - Unlock(); } } From mmlr at mail.berlios.de Wed Feb 20 01:52:05 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 20 Feb 2008 01:52:05 +0100 Subject: [Haiku-commits] r24028 - haiku/trunk/src/add-ons/kernel/debugger Message-ID: <200802200052.m1K0q5XR012854@sheep.berlios.de> Author: mmlr Date: 2008-02-20 01:52:05 +0100 (Wed, 20 Feb 2008) New Revision: 24028 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24028&view=rev Modified: haiku/trunk/src/add-ons/kernel/debugger/Jamfile Log: I really thought that such a small change wouldn't break the build... Modified: haiku/trunk/src/add-ons/kernel/debugger/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/Jamfile 2008-02-20 00:42:09 UTC (rev 24027) +++ haiku/trunk/src/add-ons/kernel/debugger/Jamfile 2008-02-20 00:52:05 UTC (rev 24028) @@ -2,3 +2,4 @@ SubInclude HAIKU_TOP src add-ons kernel debugger auto_stack_trace ; SubInclude HAIKU_TOP src add-ons kernel debugger hangman ; +SubInclude HAIKU_TOP src add-ons kernel debugger invalidate_on_exit ; From stippi at mail.berlios.de Wed Feb 20 01:56:46 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 01:56:46 +0100 Subject: [Haiku-commits] r24029 - haiku/trunk/src/servers/app Message-ID: <200802200056.m1K0ukUo013157@sheep.berlios.de> Author: stippi Date: 2008-02-20 01:56:45 +0100 (Wed, 20 Feb 2008) New Revision: 24029 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24029&view=rev Modified: haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/WindowLayer.cpp haiku/trunk/src/servers/app/WindowLayer.h Log: Implemented Enable/DisableUpdates again on the app_server side. Untested. It should prevent the app_server to send any update messages to the client. It should just keep adding to the pending update sessions region until the client enabled updates again. If anything is already in the pending session, an update request will be send immediately. Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2008-02-20 00:52:05 UTC (rev 24028) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2008-02-20 00:56:45 UTC (rev 24029) @@ -705,16 +705,14 @@ { STRACE(("ServerWindow %s: Message AS_ENABLE_UPDATES unimplemented\n", Title())); -// TODO: AS_ENABLE_UPDATES - //fWindowLayer->EnableUpdateRequests(); + fWindowLayer->EnableUpdateRequests(); break; } case AS_DISABLE_UPDATES: { STRACE(("ServerWindow %s: Message AS_DISABLE_UPDATES unimplemented\n", Title())); -// TODO: AS_DISABLE_UPDATES - //fWindowLayer->DisableUpdateRequests(); + fWindowLayer->DisableUpdateRequests(); break; } case AS_NEEDS_UPDATE: Modified: haiku/trunk/src/servers/app/WindowLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/WindowLayer.cpp 2008-02-20 00:52:05 UTC (rev 24028) +++ haiku/trunk/src/servers/app/WindowLayer.cpp 2008-02-20 00:56:45 UTC (rev 24029) @@ -111,6 +111,7 @@ fPendingUpdateSession(&fUpdateSessions[1]), fUpdateRequested(false), fInUpdate(false), + fUpdatesEnabled(true), // windows start hidden fHidden(true), @@ -701,18 +702,23 @@ } } +// DisableUpdateRequests +void +WindowLayer::DisableUpdateRequests() +{ + fUpdatesEnabled = false; +} + + // EnableUpdateRequests void WindowLayer::EnableUpdateRequests() { -// fUpdateRequestsEnabled = true; -/* if (fCumulativeRegion.CountRects() > 0) { - GetRootLayer()->MarkForRedraw(fCumulativeRegion); - GetRootLayer()->TriggerRedraw(); - }*/ + fUpdatesEnabled = true; + if (!fUpdateRequested && fPendingUpdateSession->IsUsed()) + _SendUpdateMessage(); } - // #pragma mark - @@ -1814,6 +1820,9 @@ void WindowLayer::_SendUpdateMessage() { + if (!fUpdatesEnabled) + return; + BMessage message(_UPDATE_); ServerWindow()->SendMessageToClient(&message); Modified: haiku/trunk/src/servers/app/WindowLayer.h =================================================================== --- haiku/trunk/src/servers/app/WindowLayer.h 2008-02-20 00:52:05 UTC (rev 24028) +++ haiku/trunk/src/servers/app/WindowLayer.h 2008-02-20 00:56:45 UTC (rev 24029) @@ -104,8 +104,8 @@ // shortcut for invalidating just one view void InvalidateView(ViewLayer* view, BRegion& layerRegion); + void DisableUpdateRequests(); void EnableUpdateRequests(); - void DisableUpdateRequests(); void BeginUpdate(BPrivate::PortLink& link); void EndUpdate(); @@ -335,6 +335,7 @@ // and consistent update session bool fUpdateRequested : 1; bool fInUpdate : 1; + bool fUpdatesEnabled : 1; bool fHidden : 1; bool fMinimized : 1; From mmu_man at mail.berlios.de Wed Feb 20 02:12:54 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 20 Feb 2008 02:12:54 +0100 Subject: [Haiku-commits] r24030 - haiku/trunk/3rdparty/mmu_man/onlinedemo Message-ID: <200802200112.m1K1Cs6m014242@sheep.berlios.de> Author: mmu_man Date: 2008-02-20 02:12:53 +0100 (Wed, 20 Feb 2008) New Revision: 24030 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24030&view=rev Modified: haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php Log: * qemu 0.9.1 needs ":" before vnc display number. * it seems newer qemu support "wacom-tabled" usb emulation... behaves differently but doesn't work better (worse actually), (does the driver actually reports absolute position at all ??) Modified: haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php =================================================================== --- haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php 2008-02-20 00:56:45 UTC (rev 24029) +++ haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php 2008-02-20 01:12:53 UTC (rev 24030) @@ -34,11 +34,15 @@ define("SESSION_TIMEOUT", "10m"); // path to qemu binary -define("QEMU_BIN", "/usr/bin/qemu"); +//define("QEMU_BIN", "/usr/bin/qemu"); +define("QEMU_BIN", "/usr/local/bin/qemu"); // default arguments: no network, emulate tablet, readonly image file. -define("QEMU_ARGS","-net none -usbdevice tablet -snapshot"); +define("QEMU_ARGS","-net none -usbdevice wacom-tablet -k en-us -snapshot"); +//define("QEMU_ARGS","-net none -usbdevice wacom-tablet -k fr -snapshot"); // absolute path to the image. -define("QEMU_IMAGE_PATH","/home/revol/haiku/trunk/generated/haiku.image"); +define("QEMU_IMAGE_PATH","/home/revol/haiku/trunk/generated.x86/haiku.image"); +// qemu 0.8.2 needs "", qemu 0.9.1 needs ":" +define("QEMU_VNC_PREFIX", ":"); // name of session and pid files in /tmp define("QEMU_SESSFILE_TMPL", "qemu-haiku-session-"); @@ -153,7 +157,7 @@ return $idx; } $pidfile = make_qemu_pidfile_name($idx); - $cmd = QEMU_BIN . " " . QEMU_ARGS . " -vnc " . vnc_display() . " -pidfile " . $pidfile . " " . QEMU_IMAGE_PATH; + $cmd = QEMU_BIN . " " . QEMU_ARGS . " -vnc " . QEMU_VNC_PREFIX . vnc_display() . " -pidfile " . $pidfile . " " . QEMU_IMAGE_PATH; if (file_exists($pidfile)) unlink($pidfile); From korli at users.berlios.de Wed Feb 20 08:59:44 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 20 Feb 2008 08:59:44 +0100 Subject: [Haiku-commits] r24025 - in haiku/trunk: build/jam src/add-ons/kernel/debugger src/add-ons/kernel/debugger/invalidate_on_exit src/servers/app In-Reply-To: <200802200040.m1K0e8aM012105@sheep.berlios.de> References: <200802200040.m1K0e8aM012105@sheep.berlios.de> Message-ID: 2008/2/20, mmlr at BerliOS : > + message[1] = 'KDLE'; // message code > + message[2] = 0; // flags > + Maybe move this message code in a private header, used by both the app_server and the debugger addon ? Bye, J?r?me From mmlr at mlotz.ch Wed Feb 20 09:15:22 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Wed, 20 Feb 2008 09:15:22 +0100 Subject: [Haiku-commits] r24025 - in haiku/trunk: build/jam src/add-ons/kernel/debugger src/add-ons/kernel/debugger/invalidate_on_exit src/servers/app In-Reply-To: References: <200802200040.m1K0e8aM012105@sheep.berlios.de> Message-ID: <20080220080729.M89565@mlotz.ch> On Wed, 20 Feb 2008 08:59:44 +0100, J?r?me Duval wrote > 2008/2/20, mmlr at BerliOS : > > + message[1] = 'KDLE'; // message code > > + message[2] = 0; // flags > > + > > Maybe move this message code in a private header, used by both the > app_server and the debugger addon ? Yeah, in principle yes. I just didn't feel like adding any more overhead with additional files and inclusions ;-). To do this properly also the link_message header should be included so a real message_header and the define for the port link message code can be used. This should be seen as a temporary thing though until we disable or make the kernel debugger less easy to get into. But feel free to fix this if you want. If you all find it important enough, I will look into fixing it myself, but only if you really think it's worth the extra work. Regards Michael From stippi at mail.berlios.de Wed Feb 20 10:56:26 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 10:56:26 +0100 Subject: [Haiku-commits] r24031 - haiku/trunk/src/kits/interface Message-ID: <200802200956.m1K9uQVN001734@sheep.berlios.de> Author: stippi Date: 2008-02-20 10:56:26 +0100 (Wed, 20 Feb 2008) New Revision: 24031 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24031&view=rev Modified: haiku/trunk/src/kits/interface/ColumnTypes.cpp Log: * If bitmaps are drawn with alpha channel, it helps to setup the correct alpha mode. Thanks to Ralf Schuelke for pointing this out. * Also check the bitmap color space and only use alpha drawing for bitmaps with valid alpha channel. * Don't just reset the parent to B_OP_OVER, but use the previous mode. Modified: haiku/trunk/src/kits/interface/ColumnTypes.cpp =================================================================== --- haiku/trunk/src/kits/interface/ColumnTypes.cpp 2008-02-20 01:12:53 UTC (rev 24030) +++ haiku/trunk/src/kits/interface/ColumnTypes.cpp 2008-02-20 09:56:26 UTC (rev 24031) @@ -596,9 +596,20 @@ x = rect.right - kTEXT_MARGIN - r.Width(); break; } - parent->SetDrawingMode(B_OP_ALPHA); + // setup drawing mode according to bitmap color space, + // restore previous mode after drawing + drawing_mode oldMode = parent->DrawingMode(); + if (bitmap->ColorSpace() == B_RGBA32 + || bitmap->ColorSpace() == B_RGBA32_BIG) { + parent->SetDrawingMode(B_OP_ALPHA); + parent->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); + } else { + parent->SetDrawingMode(B_OP_OVER); + } + parent->DrawBitmap(bitmap, BPoint(x, y)); - parent->SetDrawingMode(B_OP_OVER); + + parent->SetDrawingMode(oldMode); } } From superstippi at gmx.de Wed Feb 20 12:09:36 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 20 Feb 2008 12:09:36 +0100 Subject: [Haiku-commits] r24030 - haiku/trunk/3rdparty/mmu_man/onlinedemo In-Reply-To: <200802200112.m1K1Cs6m014242@sheep.berlios.de> References: <200802200112.m1K1Cs6m014242@sheep.berlios.de> Message-ID: <20080220120936.1071.1@stippis2.1203501749.fake> mmu_man at BerliOS wrote (2008-02-20, 02:12:54 [+0100]): > Author: mmu_man > Date: 2008-02-20 02:12:53 +0100 (Wed, 20 Feb 2008) New Revision: 24030 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24030&view=rev > > Modified: > haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php > Log: > * qemu 0.9.1 needs ":" before vnc display number. > * it seems newer qemu support "wacom-tabled" usb emulation... behaves > differently but doesn't work better (worse actually), (does the driver > actually reports absolute position at all ??) I think you need to provide more info :-). The driver is tested with quite a lot of real Wacom tablets and works in absolute mode of course. What do you get from usb_dev_info? What is the observed behaviour exactly? By default, Wacom tablets act as HID mouse device (like if the pen was the mouse, relative mode). Our usb_hid driver ignores HID devices with Wacom vendor id (0x056a IIRC). If the device has correct vendor ID and works at all, then our Wacom driver picks it up. Maybe it pretends to be a device which the driver thinks it supports but has never been tested properly. In the input_server team, there should be a thread with the name of the tablet that was recognized. Could you please check and provide all this info? Best regards, -Stephan From jackburton at mail.berlios.de Wed Feb 20 11:37:11 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 20 Feb 2008 11:37:11 +0100 Subject: [Haiku-commits] r24032 - haiku/trunk/src/preferences/network Message-ID: <200802201037.m1KAbBgG005699@sheep.berlios.de> Author: jackburton Date: 2008-02-20 11:37:11 +0100 (Wed, 20 Feb 2008) New Revision: 24032 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24032&view=rev Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp haiku/trunk/src/preferences/network/EthernetSettingsView.h haiku/trunk/src/preferences/network/settings.cpp Log: Disable the apply button when settings have been...er.. applied. Do some enabling/disabling of the revert button too. Initialize Settings::fAuto to a default value on construction. Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2008-02-20 09:56:26 UTC (rev 24031) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2008-02-20 10:37:11 UTC (rev 24032) @@ -56,6 +56,16 @@ #include "AutoDeleter.h" +static void +SetupTextControl(BTextControl *control) +{ + // TODO: Disallow characters, etc. + // Would be nice to have a real + // formatted input control + control->SetModificationMessage(new BMessage(kMsgChange)); +} + + bool EthernetSettingsView::_PrepareRequest(struct ifreq& request, const char* name) { @@ -116,6 +126,11 @@ { fApplyButton->SetTarget(this); fRevertButton->SetTarget(this); + fIPTextControl->SetTarget(this); + fNetMaskTextControl->SetTarget(this); + fGatewayTextControl->SetTarget(this); + fPrimaryDNSTextControl->SetTarget(this); + fSecondaryDNSTextControl->SetTarget(this); fDeviceMenuField->Menu()->SetTargetForItems(this); fTypeMenuField->Menu()->SetTargetForItems(this); @@ -175,11 +190,13 @@ fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL); fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + spacing); fIPTextControl->ResizeToPreferred(); + SetupTextControl(fIPTextControl); AddChild(fIPTextControl); fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL); fNetMaskTextControl->MoveTo( fIPTextControl->Frame().LeftBottom() + spacing); + SetupTextControl(fNetMaskTextControl); AddChild(fNetMaskTextControl); fNetMaskTextControl->ResizeToPreferred(); @@ -187,6 +204,7 @@ NULL); fGatewayTextControl->MoveTo( fNetMaskTextControl->Frame().LeftBottom() + spacing); + SetupTextControl(fGatewayTextControl); AddChild(fGatewayTextControl); fGatewayTextControl->ResizeToPreferred(); @@ -194,6 +212,7 @@ NULL); fPrimaryDNSTextControl->MoveTo( fGatewayTextControl->Frame().LeftBottom() + spacing); + SetupTextControl(fPrimaryDNSTextControl); AddChild(fPrimaryDNSTextControl); fPrimaryDNSTextControl->ResizeToPreferred(); @@ -201,6 +220,7 @@ NULL); fSecondaryDNSTextControl->MoveTo( fPrimaryDNSTextControl->Frame().LeftBottom() + spacing); + SetupTextControl(fSecondaryDNSTextControl); AddChild(fSecondaryDNSTextControl); fSecondaryDNSTextControl->ResizeToPreferred(); @@ -209,6 +229,7 @@ fRevertButton->ResizeToPreferred(); fRevertButton->MoveTo( fSecondaryDNSTextControl->Frame().LeftBottom() + spacing); + fRevertButton->SetEnabled(false); AddChild(fRevertButton); fApplyButton = new BButton(frame, "apply", "Apply", new BMessage(kMsgApply)); @@ -330,6 +351,9 @@ fPrimaryDNSTextControl->Text())); fCurrentSettings->fNameservers.AddItem(new BString( fSecondaryDNSTextControl->Text())); + + fApplyButton->SetEnabled(false); + fRevertButton->SetEnabled(true); } @@ -437,6 +461,8 @@ case kMsgMode: if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) _EnableTextControls(strcmp(item->Label(), "DHCP") != 0); + fApplyButton->SetEnabled(true); + fRevertButton->SetEnabled(true); break; case kMsgInfo: { const char* name; @@ -453,10 +479,14 @@ } case kMsgRevert: _ShowConfiguration(fCurrentSettings); + fRevertButton->SetEnabled(false); break; case kMsgApply: _SaveConfiguration(); break; + case kMsgChange: + fApplyButton->SetEnabled(true); + break; default: BView::MessageReceived(message); } Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.h 2008-02-20 09:56:26 UTC (rev 24031) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.h 2008-02-20 10:37:11 UTC (rev 24032) @@ -28,7 +28,9 @@ static const uint32 kMsgField = 'fild'; static const uint32 kMsgInfo = 'info'; static const uint32 kMsgMode = 'mode'; +static const uint32 kMsgChange = 'chng'; + class EthernetSettingsView : public BView { public: EthernetSettingsView(BRect frame); Modified: haiku/trunk/src/preferences/network/settings.cpp =================================================================== --- haiku/trunk/src/preferences/network/settings.cpp 2008-02-20 09:56:26 UTC (rev 24031) +++ haiku/trunk/src/preferences/network/settings.cpp 2008-02-20 10:37:11 UTC (rev 24032) @@ -31,6 +31,8 @@ #include Settings::Settings(const char *name) + : + fAuto(true) { fSocket = socket(AF_INET, SOCK_DGRAM, 0); fName = name; From stippi at mail.berlios.de Wed Feb 20 13:27:36 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 13:27:36 +0100 Subject: [Haiku-commits] r24033 - haiku/trunk/src/kits/interface Message-ID: <200802201227.m1KCRaBV002104@sheep.berlios.de> Author: stippi Date: 2008-02-20 13:27:36 +0100 (Wed, 20 Feb 2008) New Revision: 24033 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24033&view=rev Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp Log: * Small code cleanups, a bigger style cleanup should be done, but I didn't want to mix too much cleanups into real changes. * Got rid of the weird lines between rows. * Tweaked colors (selections are usually dark everywhere else in Haiku). * Implemented slightly tinting alternating rows. * Removed the code duplication to figure out the appropriate background row color, fixed some inconsistencies between Draw() and RedrawColumn() in this regard. TODO: Default colors should be computed based on current panel color though. TODO: Figure out why the outline view does not scroll (at least not visibly) when the vertical scroll bar is used. TODO: Remove remaining redraw bugs. I observe a column of pixels not being updated in some cases when resizing columns. Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-20 10:37:11 UTC (rev 24032) +++ haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-20 12:27:36 UTC (rev 24033) @@ -154,15 +154,7 @@ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -/* -static const rgb_color kTitleColor = {215, 215, 215, 255}; -static const rgb_color kTitleTextColor = { 0, 0, 0, 255 }; -static const rgb_color kDefaultBackgroundColor = {236, 236, 236, 255}; -static const rgb_color kRowDividerColor = {148, 148, 148, 255}; -static const rgb_color kDefaultSelectionColor = {255, 255, 255, 255}; -static const rgb_color kDefaultEditColor = {180, 180, 180, 180}; -static const rgb_color kNonFocusSelectionColor = {220, 220, 220, 255}; -*/ +static const float kTintedLineTint = 0.7 * B_NO_TINT + 0.3 * B_DARKEN_1_TINT; static const float kTitleHeight = 17.0; static const float kLatchWidth = 15.0; @@ -173,9 +165,9 @@ {236, 236, 236, 255}, // B_COLOR_BACKGROUND { 0, 0, 0, 255}, // B_COLOR_TEXT {148, 148, 148, 255}, // B_COLOR_ROW_DIVIDER - {255, 255, 255, 255}, // B_COLOR_SELECTION + {190, 190, 190, 255}, // B_COLOR_SELECTION { 0, 0, 0, 255}, // B_COLOR_SELECTION_TEXT - {220, 220, 220, 255}, // B_COLOR_NON_FOCUS_SELECTION + {200, 200, 200, 255}, // B_COLOR_NON_FOCUS_SELECTION {180, 180, 180, 180}, // B_COLOR_EDIT_BACKGROUND { 0, 0, 0, 255}, // B_COLOR_EDIT_TEXT {215, 215, 215, 255}, // B_COLOR_HEADER_BACKGROUND @@ -1573,8 +1565,7 @@ void BColumnListView::Refresh() { - if(LockLooper()) - { + if (LockLooper()) { Invalidate(); fOutlineView->FixScrollBar (true); fOutlineView->Invalidate(); @@ -1780,13 +1771,10 @@ { fColumns->RemoveItem((void*) column); - if (-1 == index) - { + if (-1 == index) { // Re-add the column at the end of the list. fColumns->AddItem((void*) column); - } - else - { + } else { fColumns->AddItem((void*) column, index); } } @@ -2513,148 +2501,138 @@ void OutlineView::RedrawColumn(BColumn *column, float leftEdge, bool isFirstColumn) { - if (column) { - font_height fh; - GetFontHeight(&fh); - float line = 0.0; - for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow(); - line += iterator.CurrentRow()->Height() + 1, iterator.GoToNext()) { - BRow *row = iterator.CurrentRow(); - float rowHeight = row->Height(); - if (line > fVisibleRect.bottom) - break; - - if (line + rowHeight >= fVisibleRect.top) { - BRect sourceRect(0, 0, column->Width(), rowHeight); - BRect destRect(leftEdge, line, leftEdge + column->Width(), line + rowHeight); - - #if DOUBLE_BUFFERED_COLUMN_RESIZE - fDrawBuffer->Lock(); - if (row->fNextSelected != 0) { - if(fEditMode) { - fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - } else { - fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_SELECTION)); - fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_SELECTION)); - } + // TODO: Remove code duplication (private function which takes a view + // pointer, pass "this" in non-double buffered mode)! + // Watch out for sourceRect versus destRect though! + if (!column) + return; + + font_height fh; + GetFontHeight(&fh); + float line = 0.0; + bool tintedLine = true; + for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow(); + line += iterator.CurrentRow()->Height() + 1, iterator.GoToNext()) { + BRow *row = iterator.CurrentRow(); + float rowHeight = row->Height(); + if (line > fVisibleRect.bottom) + break; + tintedLine = !tintedLine; + + if (line + rowHeight >= fVisibleRect.top) { + BRect sourceRect(0, 0, column->Width(), rowHeight); + BRect destRect(leftEdge, line, leftEdge + column->Width(), line + rowHeight); + + rgb_color highColor; + rgb_color lowColor; + if (row->fNextSelected != 0) { + if (fEditMode) { + highColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND); + lowColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND); } else { - fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); - fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND)); + highColor = fMasterView->Color(B_COLOR_SELECTION); + lowColor = fMasterView->Color(B_COLOR_SELECTION); } - BFont font; - GetFont(&font); - fDrawBufferView->SetFont(&font); - fDrawBufferView->FillRect(sourceRect); - - if (isFirstColumn) { - // If this is the first column, double buffer drawing the latch too. - destRect.left += iterator.CurrentLevel() * kOutlineLevelIndent - - fMasterView->LatchWidth(); - sourceRect.left += iterator.CurrentLevel() * kOutlineLevelIndent - - fMasterView->LatchWidth(); - - LatchType pos = B_NO_LATCH; - if (row->HasLatch()) - pos = row->fIsExpanded ? B_OPEN_LATCH : B_CLOSED_LATCH; - - BRect latchRect(sourceRect); - latchRect.right = latchRect.left + fMasterView->LatchWidth(); - fMasterView->DrawLatch(fDrawBufferView, latchRect, pos, row); - } - - BField *field = row->GetField(column->fFieldID); - if (field) { - BRect fieldRect(sourceRect); - if (isFirstColumn) - fieldRect.left += fMasterView->LatchWidth(); - - #if CONSTRAIN_CLIPPING_REGION - BRegion clipRegion; - clipRegion.Set(fieldRect); - fDrawBufferView->ConstrainClippingRegion(&clipRegion); - fDrawBufferView->PushState(); - #endif - fDrawBufferView->SetHighColor(fMasterView->Color(row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT)); - float baseline = floor(fieldRect.top + fh.ascent - + (fieldRect.Height()+1-(fh.ascent+fh.descent))/2); - fDrawBufferView->MovePenTo(fieldRect.left + 8, baseline); - column->DrawField(field, fieldRect, fDrawBufferView); - #if CONSTRAIN_CLIPPING_REGION - fDrawBufferView->PopState(); - fDrawBufferView->ConstrainClippingRegion(NULL); - #endif - } - - if (fFocusRow == row) { - if(!fEditMode) { - fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); - fDrawBufferView->StrokeRect(BRect(-1, sourceRect.top, 10000.0, sourceRect.bottom - 1)); - } - } - + } else { + highColor = fMasterView->Color(B_COLOR_BACKGROUND); + lowColor = fMasterView->Color(B_COLOR_BACKGROUND); + } + if (tintedLine) + lowColor = tint_color(lowColor, kTintedLineTint); + + +#if DOUBLE_BUFFERED_COLUMN_RESIZE + fDrawBuffer->Lock(); + + fDrawBufferView->SetHighColor(highColor); + fDrawBufferView->SetLowColor(lowColor); + + BFont font; + GetFont(&font); + fDrawBufferView->SetFont(&font); + fDrawBufferView->FillRect(sourceRect, B_SOLID_LOW); + + if (isFirstColumn) { + // If this is the first column, double buffer drawing the latch too. + destRect.left += iterator.CurrentLevel() * kOutlineLevelIndent + - fMasterView->LatchWidth(); + sourceRect.left += iterator.CurrentLevel() * kOutlineLevelIndent + - fMasterView->LatchWidth(); + + LatchType pos = B_NO_LATCH; + if (row->HasLatch()) + pos = row->fIsExpanded ? B_OPEN_LATCH : B_CLOSED_LATCH; + + BRect latchRect(sourceRect); + latchRect.right = latchRect.left + fMasterView->LatchWidth(); + fMasterView->DrawLatch(fDrawBufferView, latchRect, pos, row); + } + + BField *field = row->GetField(column->fFieldID); + if (field) { + BRect fieldRect(sourceRect); + if (isFirstColumn) + fieldRect.left += fMasterView->LatchWidth(); + + #if CONSTRAIN_CLIPPING_REGION + BRegion clipRegion; + clipRegion.Set(fieldRect); + fDrawBufferView->ConstrainClippingRegion(&clipRegion); + fDrawBufferView->PushState(); + #endif + fDrawBufferView->SetHighColor(fMasterView->Color(row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT)); + float baseline = floor(fieldRect.top + fh.ascent + + (fieldRect.Height()+1-(fh.ascent+fh.descent))/2); + fDrawBufferView->MovePenTo(fieldRect.left + 8, baseline); + column->DrawField(field, fieldRect, fDrawBufferView); + #if CONSTRAIN_CLIPPING_REGION + fDrawBufferView->PopState(); + fDrawBufferView->ConstrainClippingRegion(NULL); + #endif + } + + if (fFocusRow == row && !fEditMode && fMasterView->IsFocus() + && Window()->IsActive()) { fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER)); - // StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2)); - // StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1)); - fDrawBufferView->StrokeLine(BPoint(0, rowHeight), BPoint(Bounds().right, rowHeight)); - - fDrawBufferView->Sync(); - fDrawBuffer->Unlock(); - SetDrawingMode(B_OP_OVER); - DrawBitmap(fDrawBuffer, sourceRect, destRect); - - #else - - if (row->fNextSelected != 0) { - if(fEditMode) { - SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - } - else { - SetHighColor(fMasterView->Color(B_COLOR_SELECTION)); - SetLowColor(fMasterView->Color(B_COLOR_SELECTION)); - } - } else { - SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); - SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND)); - } - - FillRect(destRect); - - BField *field = row->GetField(column->fFieldID); - if (field) { - #if CONSTRAIN_CLIPPING_REGION - BRegion clipRegion; - clipRegion.Set(destRect); - ConstrainClippingRegion(&clipRegion); - PushState(); - #endif - SetHighColor(fColorList[row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT]); - float baseline = floor(destRect.top + fh.ascent - + (destRect.Height()+1-(fh.ascent+fh.descent))/2); - MovePenTo(destRect.left + 8, baseline); - column->DrawField(field, destRect, this); - #if CONSTRAIN_CLIPPING_REGION - PopState(); - ConstrainClippingRegion(NULL); - #endif - } - - if (fFocusRow == row) { - if(!fEditMode) { - SetHighColor(fColorList[B_COLOR_SELECTION_TEXT]); - StrokeRect(BRect(0, destRect.top, 10000.0, destRect.bottom - 1)); - } - } - - rgb_color color = HighColor(); - SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER)); - // StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2)); - // StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1)); - StrokeLine(BPoint(0, line + rowHeight), BPoint(Bounds().right, line + rowHeight)); - SetHighColor(color); + fDrawBufferView->StrokeRect(BRect(-1, sourceRect.top, 10000.0, sourceRect.bottom)); + } + + fDrawBufferView->Sync(); + fDrawBuffer->Unlock(); + SetDrawingMode(B_OP_COPY); + DrawBitmap(fDrawBuffer, sourceRect, destRect); + +#else + + SetHighColor(highColor); + SetLowColor(lowColor); + FillRect(destRect, B_SOLID_LOW); + + BField *field = row->GetField(column->fFieldID); + if (field) { + #if CONSTRAIN_CLIPPING_REGION + BRegion clipRegion; + clipRegion.Set(destRect); + ConstrainClippingRegion(&clipRegion); + PushState(); #endif + SetHighColor(fColorList[row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT]); + float baseline = floor(destRect.top + fh.ascent + + (destRect.Height()+1-(fh.ascent+fh.descent))/2); + MovePenTo(destRect.left + 8, baseline); + column->DrawField(field, destRect, this); + #if CONSTRAIN_CLIPPING_REGION + PopState(); + ConstrainClippingRegion(NULL); + #endif } + + if (fFocusRow == row && !fEditMode && fMasterView->IsFocus() + && Window()->IsActive()) { + SetHighColor(fColorList[B_COLOR_ROW_DIVIDER]); + StrokeRect(BRect(0, destRect.top, 10000.0, destRect.bottom)); + } +#endif } } } @@ -2670,18 +2648,37 @@ GetFontHeight(&fh); float line = 0.0; + bool tintedLine = true; int32 numColumns = fColumns->CountItems(); for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow(); iterator.GoToNext()) { BRow *row = iterator.CurrentRow(); if (line > invalidBounds.bottom) break; - + + tintedLine = !tintedLine; float rowHeight = row->Height(); if (line > invalidBounds.top - rowHeight) { bool isFirstColumn = true; float fieldLeftEdge = MAX(kLeftMargin, fMasterView->LatchWidth()); + + // setup background color + rgb_color lowColor; + if (row->fNextSelected != 0) { + if (Window()->IsActive()) { + if (fEditMode) + lowColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND); + else + lowColor = fMasterView->Color(B_COLOR_SELECTION); + } + else + lowColor = fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION); + } else + lowColor = fMasterView->Color(B_COLOR_BACKGROUND); + if (tintedLine) + lowColor = tint_color(lowColor, kTintedLineTint); + for (int columnIndex = 0; columnIndex < numColumns; columnIndex++) { BColumn *column = (BColumn*) fColumns->ItemAt(columnIndex); if (!column->IsVisible()) @@ -2698,17 +2695,7 @@ // This happens when a column is indented past the // beginning of the next column. - if (row->fNextSelected != 0) { - if (Window()->IsActive()) { - if(fEditMode) - SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - else - SetHighColor(fMasterView->Color(B_COLOR_SELECTION)); - } - else - SetHighColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION)); - } else - SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); + SetHighColor(lowColor); BRect destRect(fullRect); if (isFirstColumn) { @@ -2721,7 +2708,6 @@ clippedFirstColumn = true; } - FillRect(BRect(0, line, MAX(kLeftMargin, fMasterView->LatchWidth()), line + row->Height())); } @@ -2760,21 +2746,10 @@ row); } } - - if (row->fNextSelected != 0) { - if (Window()->IsActive()) { - if(fEditMode) - SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - else - SetLowColor(fMasterView->Color(B_COLOR_SELECTION)); - } - else - SetLowColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION)); - } else - SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND)); SetHighColor(fMasterView->HighColor()); // The master view just holds the high color for us. + SetLowColor(lowColor); BField *field = row->GetField(column->fFieldID); if (field) { @@ -2802,39 +2777,23 @@ } if (fieldLeftEdge <= invalidBounds.right) { - if (row->fNextSelected != 0) { - if (Window()->IsActive()) { - if(fEditMode) - SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); - else - SetHighColor(fMasterView->Color(B_COLOR_SELECTION)); - } - else - SetHighColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION)); - } else - SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); - + SetHighColor(lowColor); FillRect(BRect(fieldLeftEdge, line, invalidBounds.right, line + rowHeight)); } } - - if (fFocusRow == row && fMasterView->IsFocus() && Window()->IsActive()) { - if(!fEditMode) { - SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); - StrokeRect(BRect(0, line, 10000.0, line + rowHeight - 1)); - } + + // indicate the keyboard focus row + if (fFocusRow == row && !fEditMode && fMasterView->IsFocus() && Window()->IsActive()) { + SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER)); + StrokeRect(BRect(0, line, 10000.0, line + rowHeight)); } - rgb_color color = HighColor(); - SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER)); -// StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2)); -// StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1)); - StrokeLine(BPoint(invalidBounds.left, line + rowHeight), BPoint(invalidBounds.right, line + rowHeight)); - SetHighColor(color); + line += rowHeight + 1; } if (line <= invalidBounds.bottom) { + // fill background below last item SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); FillRect(BRect(invalidBounds.left, line, invalidBounds.right, invalidBounds.bottom)); } @@ -3036,24 +2995,24 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage */*message*/) { - if(!fMouseDown) { + if (!fMouseDown) { // Update fCurrentField bool handle_field = false; BField *new_field = 0; BRow *new_row = 0; BColumn *new_column = 0; BRect new_rect(0,0,0,0); - if(position.y >=0 ) { + if (position.y >=0 ) { float top; int32 indent; BRow *row = FindRow(position.y, &indent, &top); - if(row && position.x >=0 ) { + if (row && position.x >=0 ) { float x=0; - for(int32 c=0;cCountColumns();c++) { + for (int32 c=0;cCountColumns();c++) { new_column = fMasterView->ColumnAt(c); if (!new_column->IsVisible()) continue; - if((MAX(kLeftMargin, fMasterView->LatchWidth())+x)+new_column->Width() > position.x) { + if ((MAX(kLeftMargin, fMasterView->LatchWidth())+x)+new_column->Width() > position.x) { if(new_column->WantsEvents()) { new_field = row->GetField(c); new_row = row; @@ -3070,9 +3029,9 @@ } // Handle mouse moved - if(handle_field) { - if(new_field != fCurrentField) { - if(fCurrentField) { + if (handle_field) { + if (new_field != fCurrentField) { + if (fCurrentField) { fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW); } @@ -3091,7 +3050,7 @@ } } } else { - if(fCurrentField) { + if (fCurrentField) { fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW); fCurrentField = 0; @@ -3100,11 +3059,10 @@ } } } else { - if(fCurrentField) { - if(fFieldRect.Contains(position)) { - if ( fCurrentCode == B_OUTSIDE_VIEW - || fCurrentCode == B_EXITED_VIEW - ) { + if (fCurrentField) { + if (fFieldRect.Contains(position)) { + if (fCurrentCode == B_OUTSIDE_VIEW + || fCurrentCode == B_EXITED_VIEW) { fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentField, fFieldRect, position, 1, fCurrentCode = B_ENTERED_VIEW); } else { @@ -3112,9 +3070,8 @@ fCurrentField, fFieldRect, position, 1, fCurrentCode = B_INSIDE_VIEW); } } else { - if ( fCurrentCode == B_INSIDE_VIEW - || fCurrentCode == B_ENTERED_VIEW - ) { + if (fCurrentCode == B_INSIDE_VIEW + || fCurrentCode == B_ENTERED_VIEW) { fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentField, fFieldRect, position, 1, fCurrentCode = B_EXITED_VIEW); } else { @@ -3125,7 +3082,7 @@ } } - if(!fEditMode) { + if (!fEditMode) { switch (fCurrentState) { case LATCH_CLICKED: @@ -3182,8 +3139,7 @@ BRow *target = FindRow(position.y, &indent, &top); if(target==fRollOverRow) break; - if(fRollOverRow) - { + if (fRollOverRow) { BRect rect; FindRect(fRollOverRow, &rect); Invalidate(rect); @@ -3202,8 +3158,7 @@ PopState(); #endif } else { - if(fRollOverRow) - { + if (fRollOverRow) { BRect rect; FindRect(fRollOverRow, &rect); Invalidate(rect); @@ -3218,12 +3173,12 @@ void OutlineView::MouseUp(BPoint position) { - if(fCurrentField) { + if (fCurrentField) { fCurrentColumn->MouseUp(fMasterView,fCurrentRow,fCurrentField); fMouseDown = false; } - if(!fEditMode) { + if (!fEditMode) { switch (fCurrentState) { case LATCH_CLICKED: if (fLatchRect.Contains(position)) @@ -3254,7 +3209,7 @@ } } } -} // end of MouseUp() +} void OutlineView::MessageReceived(BMessage *message) { @@ -3453,8 +3408,7 @@ if (parentRow) { if (parentRow->fIsExpanded) fItemsHeight -= subTreeHeight + 1; - } - else { + } else { fItemsHeight -= subTreeHeight + 1; } FixScrollBar(false); @@ -3791,10 +3745,8 @@ void OutlineView::ScrollTo(const BRow* Row) { BRect rect; - if( true == FindRect(Row, &rect) ) - { + if (FindRect(Row, &rect)) ScrollTo(BPoint(rect.left, rect.top)); - } } @@ -3834,12 +3786,11 @@ void OutlineView::SetFocusRow(BRow* Row, bool Select) { - if (Row) - { - if(Select) + if (Row) { + if (Select) AddToSelection(Row); - if(fFocusRow == Row) + if (fFocusRow == Row) return; Invalidate(fFocusRowRect); // invalidate previous From axeld at pinc-software.de Wed Feb 20 14:27:52 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 20 Feb 2008 14:27:52 +0100 CET Subject: [Haiku-commits] r24033 - haiku/trunk/src/kits/interface In-Reply-To: <200802201227.m1KCRaBV002104@sheep.berlios.de> Message-ID: <18674260231-BeMail@zon> stippi at BerliOS wrote: > Modified: > haiku/trunk/src/kits/interface/ColumnListView.cpp Before you spend more time on this one, I think we should think about replacing it altogether with a clean version, API-wise. Bye, Axel. From stippi at mail.berlios.de Wed Feb 20 15:23:14 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 20 Feb 2008 15:23:14 +0100 Subject: [Haiku-commits] r24034 - haiku/trunk/src/apps/drivesetup Message-ID: <200802201423.m1KENEP4012658@sheep.berlios.de> Author: stippi Date: 2008-02-20 15:23:13 +0100 (Wed, 20 Feb 2008) New Revision: 24034 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24034&view=rev Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp Log: * Maintain the previously selected partition when rescanning drives (ie also when mounting/unmounting a partition). * Set the enabled state of the Unmount menu item when a partition is not mounted (was using previous state from last partition). Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-20 12:27:36 UTC (rev 24033) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2008-02-20 14:23:13 UTC (rev 24034) @@ -146,6 +146,7 @@ : BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) , fCurrentDisk(NULL) + , fCurrentPartitionID(-1) , fSpaceIDMap() { BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu"); @@ -179,7 +180,7 @@ // Parition menu fPartitionMenu = new BMenu("Partition"); - fCreateMenu = new BMenu("Create"); + fCreateMenu = new BMenu("Create (not implemented)"); fPartitionMenu->AddItem(fCreateMenu); fInitMenu = new BMenu("Initialize"); @@ -224,8 +225,6 @@ // visit all disks in the system and show their contents _ScanDrives(); - - _EnabledDisableMenuItems(NULL, -1, -1); } @@ -368,6 +367,17 @@ ListPopulatorVisitor driveVisitor(fListView, diskCount, fSpaceIDMap); fDDRoster.VisitEachPartition(&driveVisitor); fDiskView->SetDiskCount(diskCount); + + // restore selection + PartitionListRow* previousSelection + = fListView->FindRow(fCurrentPartitionID); + if (previousSelection) { + fListView->AddToSelection(previousSelection); + _EnabledDisableMenuItems(fCurrentDisk, fCurrentPartitionID, + previousSelection->ParentID()); + } else { + _EnabledDisableMenuItems(NULL, -1, -1); + } } @@ -483,6 +493,7 @@ parentPartition = disk->FindDescendant(parentID); if (parentPartition) { +disk->PrepareModifications(); fCreateMenu->SetEnabled(true); BString supportedChildType; int32 cookie = 0; @@ -500,6 +511,7 @@ if (fCreateMenu->CountItems() == 0) fprintf(stderr, "Failed to get supported child types: %s\n", strerror(ret)); +disk->CancelModifications(); } else { fCreateMenu->SetEnabled(false); } @@ -512,17 +524,18 @@ fDeleteMI->SetEnabled(false); fMountMI->SetEnabled(!partition->IsMounted()); + bool unMountable = false; if (partition->IsMounted()) { // see if this partition is the boot volume BVolume volume; BVolume bootVolume; if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK && partition->GetVolume(&volume) == B_OK) { - fUnmountMI->SetEnabled(volume != bootVolume); - } else { - fUnmountMI->SetEnabled(true); - } + unMountable = volume != bootVolume; + } else + unMountable = true; } + fUnmountMI->SetEnabled(unMountable); } else { fInitMenu->SetEnabled(false); fDeleteMI->SetEnabled(false); From revol at free.fr Wed Feb 20 15:30:18 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 20 Feb 2008 15:30:18 +0100 CET Subject: [Haiku-commits] r24030 - haiku/trunk/3rdparty/mmu_man/onlinedemo In-Reply-To: <20080220120936.1071.1@stippis2.1203501749.fake> Message-ID: <2702950865-BeMail@laptop> > > mmu_man at BerliOS wrote (2008-02-20, 02:12:54 [+0100]): > > Author: mmu_man > > Date: 2008-02-20 02:12:53 +0100 (Wed, 20 Feb 2008) New Revision: > > 24030 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24030&view=rev > > > > Modified: > > haiku/trunk/3rdparty/mmu_man/onlinedemo/haiku.php > > Log: > > * qemu 0.9.1 needs ":" before vnc display number. > > * it seems newer qemu support "wacom-tabled" usb emulation... > > behaves > > differently but doesn't work better (worse actually), (does the > > driver > > actually reports absolute position at all ??) > > I think you need to provide more info :-). The driver is tested with > quite > a lot of real Wacom tablets and works in absolute mode of course. > What do > you get from usb_dev_info? What is the observed behaviour exactly? By > default, Wacom tablets act as HID mouse device (like if the pen was > the > mouse, relative mode). Our usb_hid driver ignores HID devices with > Wacom Ah that's why the default tablet doesn't help with VNC... it has a custom vendor (QEMU's I suppose). The whole purpose is to force using absolute position to get the mouse where it should be as the VNC applet finds it. > vendor id (0x056a IIRC). If the device has correct vendor ID and > works at > all, then our Wacom driver picks it up. Maybe it pretends to be a > device > which the driver thinks it supports but has never been tested > properly. In > the input_server team, there should be a thread with the name of the > tablet > that was recognized. Could you please check and provide all this > info? Yes it's probably faking a device without implementing it completely. It's not really handy as the mouse is unusable... nor is keyboard with vnc. The mouse just stays up-left, and when clicking it seems as if it was clicked and moved far away. Let's try without vnc... [Device] Class .................. 0x00 Subclass ............... 0x00 Protocol ............... 0x00 Max Endpoint 0 Packet .. 8 USB Version ............ 0x1010 Vendor ID .............. 0x056a Product ID ............. 0x0000 Product Version ........ 0x4210 Manufacturer String .... "1" Product String ......... "Wacom PenPartner" Serial Number .......... "" [Configuration 0] Configuration String . "" [Interface 0] Class .............. 0x03 Subclass ........... 0x01 Protocol ........... 0x02 Interface String ... "" [Endpoint 0] MaxPacketSize .... 8 Interval ......... 10 Type ............. Interrupt Direction ........ Input [Descriptor 0] Type ............. 0x21 Data ............. 01 10 00 01 22 6e 00 Fran?ois. From axeld at mail.berlios.de Wed Feb 20 17:48:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 20 Feb 2008 17:48:16 +0100 Subject: [Haiku-commits] r24035 - in haiku/trunk: headers/private/kernel/fs src/system/kernel/fs Message-ID: <200802201648.m1KGmGS9029822@sheep.berlios.de> Author: axeld Date: 2008-02-20 17:48:16 +0100 (Wed, 20 Feb 2008) New Revision: 24035 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24035&view=rev Modified: haiku/trunk/headers/private/kernel/fs/node_monitor.h haiku/trunk/src/system/kernel/fs/node_monitor.cpp Log: Added add_node_listener() and remove_node_listener() kernel private functions to watch a node. Modified: haiku/trunk/headers/private/kernel/fs/node_monitor.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/node_monitor.h 2008-02-20 14:23:13 UTC (rev 24034) +++ haiku/trunk/headers/private/kernel/fs/node_monitor.h 2008-02-20 16:48:16 UTC (rev 24035) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_NODE_MONITOR_H @@ -12,6 +12,16 @@ struct io_context; #ifdef __cplusplus + +// C++ only part + +class NotificationListener; + +extern status_t remove_node_listener(dev_t device, dev_t node, + NotificationListener& listener); +extern status_t add_node_listener(dev_t device, dev_t node, uint32 flags, + NotificationListener& listener); + extern "C" { #endif Modified: haiku/trunk/src/system/kernel/fs/node_monitor.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/node_monitor.cpp 2008-02-20 14:23:13 UTC (rev 24034) +++ haiku/trunk/src/system/kernel/fs/node_monitor.cpp 2008-02-20 16:48:16 UTC (rev 24035) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -109,6 +109,8 @@ status_t RemoveListener(const KMessage *eventSpecifier, NotificationListener &listener); + status_t AddListener(io_context *context, dev_t device, ino_t node, + uint32 flags, NotificationListener ¬ificationListener); status_t RemoveListener(io_context *context, dev_t device, ino_t node, NotificationListener ¬ificationListener); @@ -130,8 +132,6 @@ status_t _AddMonitorListener(io_context *context, node_monitor* monitor, uint32 flags, NotificationListener& notificationListener); - status_t _AddListener(io_context *context, dev_t device, ino_t node, - uint32 flags, NotificationListener ¬ificationListener); status_t _UpdateListener(io_context *context, dev_t device, ino_t node, uint32 flags, bool addFlags, NotificationListener ¬ificationListener); @@ -376,7 +376,7 @@ status_t -NodeMonitorService::_AddListener(io_context *context, dev_t device, ino_t node, +NodeMonitorService::AddListener(io_context *context, dev_t device, ino_t node, uint32 flags, NotificationListener& notificationListener) { TRACE(("%s(dev = %ld, node = %Ld, flags = %ld, listener = %p\n", @@ -775,7 +775,7 @@ ino_t node = eventSpecifier->GetInt64("node", -1); uint32 flags = eventSpecifier->GetInt32("flags", 0); - return _AddListener(context, device, node, flags, listener); + return AddListener(context, device, node, flags, listener); } @@ -944,6 +944,23 @@ } +status_t +remove_node_listener(dev_t device, dev_t node, NotificationListener& listener) +{ + return sNodeMonitorService.RemoveListener(get_current_io_context(true), + device, node, listener); +} + + +status_t +add_node_listener(dev_t device, dev_t node, uint32 flags, + NotificationListener& listener) +{ + return sNodeMonitorService.AddListener(get_current_io_context(true), + device, node, flags, listener); +} + + // #pragma mark - public kernel API From axeld at mail.berlios.de Wed Feb 20 17:55:06 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 20 Feb 2008 17:55:06 +0100 Subject: [Haiku-commits] r24036 - in haiku/trunk/src/system/kernel: device_manager fs Message-ID: <200802201655.m1KGt6eL030499@sheep.berlios.de> Author: axeld Date: 2008-02-20 17:55:05 +0100 (Wed, 20 Feb 2008) New Revision: 24036 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24036&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/Jamfile haiku/trunk/src/system/kernel/device_manager/probe.cpp haiku/trunk/src/system/kernel/fs/devfs.cpp Log: * Started implementing node monitoring in the devfs and device manager. * Right now, only already known loaded drivers will be monitored for changes; their devices aren't republished, though, since that would cause a deadlock in the node notification mechanism (listeners are called synchronously); need to offload that the event handling to another thread. * On changes of (known) driver directories, the device manager will now print some info to the syslog. * Fixed republish_driver() I broke recently (would skip every other node), and moved it to the driver functions section of the devfs.cpp. * Implemented currently unused unpublish_driver() function that would have to be called before reloading a driver. * If a driver is in use when it's updated, we mark it, but we don't do anything with that info when we could. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/device_manager/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/device_manager/Jamfile 2008-02-20 16:48:16 UTC (rev 24035) +++ haiku/trunk/src/system/kernel/device_manager/Jamfile 2008-02-20 16:55:05 UTC (rev 24036) @@ -1,7 +1,7 @@ SubDir HAIKU_TOP src system kernel device_manager ; UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; -UsePrivateHeaders [ FDirName kernel util ] ; +UsePrivateHeaders [ FDirName kernel util ] shared ; KernelMergeObject kernel_device_manager.o : attributes.c Modified: haiku/trunk/src/system/kernel/device_manager/probe.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/probe.cpp 2008-02-20 16:48:16 UTC (rev 24035) +++ haiku/trunk/src/system/kernel/device_manager/probe.cpp 2008-02-20 16:55:05 UTC (rev 24036) @@ -1,14 +1,12 @@ /* - * Copyright 2004-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Copyright 2002-2004, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. */ /* - Part of Device Manager Probing for consumers. - Here is all the core logic how consumers are found for one node. */ @@ -17,14 +15,17 @@ #include #include +#include +#include +#include #include -#include -#include +#include #include #include #include #include +#include #include #include @@ -68,19 +69,22 @@ static const char *kModulePaths[] = { COMMON_MODULES_DIR, "/boot/beos/system/add-ons/kernel",//SYSTEM_MODULES_DIR, - "/boot", // ToDo: this is for the bootfs boot - to be removed NULL }; class DirectoryIterator { public: - DirectoryIterator(const char *path, const char *subPath = NULL, bool recursive = false); - DirectoryIterator(const char **paths, const char *subPath = NULL, bool recursive = false); + DirectoryIterator(const char *path, const char *subPath = NULL, + bool recursive = false); + DirectoryIterator(const char **paths, const char *subPath = NULL, + bool recursive = false); ~DirectoryIterator(); - void SetTo(const char *path, const char *subPath = NULL, bool recursive = false); - void SetTo(const char **paths, const char *subPath = NULL, bool recursive = false); + void SetTo(const char *path, const char *subPath = NULL, + bool recursive = false); + void SetTo(const char **paths, const char *subPath = NULL, + bool recursive = false); status_t GetNext(KPath &path, struct stat &stat); const char *CurrentName() const { return fCurrentName; } @@ -97,7 +101,22 @@ }; -DirectoryIterator::DirectoryIterator(const char *path, const char *subPath, bool recursive) +class DirectoryWatcher : public NotificationListener { + public: + DirectoryWatcher(); + virtual ~DirectoryWatcher(); + + virtual void EventOccured(NotificationService& service, + const KMessage* event); +}; + + +static DirectoryWatcher sDirectoryWatcher; +static bool sWatching; + + +DirectoryIterator::DirectoryIterator(const char *path, const char *subPath, + bool recursive) : fDirectory(NULL), fBasePath(NULL), @@ -107,7 +126,8 @@ } -DirectoryIterator::DirectoryIterator(const char **paths, const char *subPath, bool recursive) +DirectoryIterator::DirectoryIterator(const char **paths, const char *subPath, + bool recursive) : fDirectory(NULL), fBasePath(NULL) @@ -226,7 +246,52 @@ // #pragma mark - -struct path_entry * +DirectoryWatcher::DirectoryWatcher() +{ +} + + +DirectoryWatcher::~DirectoryWatcher() +{ +} + + +void +DirectoryWatcher::EventOccured(NotificationService& service, + const KMessage* event) +{ + int32 opcode = event->GetInt32("opcode", -1); +/* + if (opcode == B_ENTRY_CREATED) + devfs_publish_directory(); +*/ + dprintf("DRIVER DIRECTORY EVENT: %ld\n", opcode); + dprintf(" device %ld\n", event->GetInt32("device", -1)); + dprintf(" node %Ld\n", event->GetInt64("node", -1)); + dprintf(" name %s\n", event->GetString("name", "")); +} + + +// #pragma mark - + + +static void +start_watching(const char *base, const char *sub) +{ + KPath path(base); + path.Append(sub); + + // TODO: create missing directories? + struct stat stat; + if (::stat(path.Path(), &stat) != 0) + return; + + add_node_listener(stat.st_dev, stat.st_ino, B_WATCH_DIRECTORY, + sDirectoryWatcher); +} + + +static struct path_entry * new_path_entry(const char *path, dev_t device, ino_t node) { path_entry *entry = (path_entry *)malloc(sizeof(path_entry)); @@ -246,7 +311,7 @@ } -struct path_entry * +static struct path_entry * copy_path_entry(path_entry *entry) { path_entry *newEntry = (path_entry *)malloc(sizeof(struct path_entry)); @@ -264,7 +329,7 @@ } -void +static void free_module_entry(module_entry *entry) { if (entry->name != NULL && entry->driver != NULL) @@ -275,7 +340,7 @@ } -struct module_entry * +static struct module_entry * new_module_entry(const char *name, driver_module_info *driver) { module_entry *entry = (module_entry *)malloc(sizeof(module_entry)); @@ -331,7 +396,8 @@ static status_t -get_next_device_node(struct list *list, uint32 *_cookie, device_node_info **_node) +get_next_device_node(struct list *list, uint32 *_cookie, + device_node_info **_node) { node_entry *entry = (node_entry *)list_get_next_item(list, (void *)*_cookie); if (entry == NULL) @@ -355,11 +421,10 @@ } -/** notify a consumer that a device he might handle is added - * fileName - file name of consumer - * (moved to end of file to avoid inlining) - */ - +/*! Notify a consumer that a device he might handle is added + fileName - file name of consumer + (moved to end of file to avoid inlining) +*/ static status_t notify_probe_by_file(device_node_info *node, const char *fileName) { @@ -387,7 +452,9 @@ TRACE(("notify_probe_by_file trying %s %s %s\n", module_name, bus, module_name + (strlen(module_name) - suffix_length + 1))); if (strlen(module_name) > suffix_length && !strncmp(module_name + (strlen(module_name) - suffix_length + 1), bus, strlen(bus)) - && !strncmp(module_name + (strlen(module_name) - sizeof(device_suffix) + 1), device_suffix, sizeof(device_suffix))) { + && !strncmp(module_name + (strlen(module_name) + - sizeof(device_suffix) + 1), device_suffix, + sizeof(device_suffix))) { // found the module res = dm_register_child_device(node, module_name, true); break; @@ -401,15 +468,14 @@ } -/** compose all possible names of Specific drivers; as there are - * multiple names which only differ in length, the most specific - * driver name gets stored in , whereas is a - * list of lengths of individual driver names with index 0 - * containing the length of the shortest and num_parts-1 the - * length of the longest name; is a supplied buffer of - * MAX_PATH+1 size - */ - +/*! Compose all possible names of Specific drivers; as there are + multiple names which only differ in length, the most specific + driver name gets stored in , whereas is a + list of lengths of individual driver names with index 0 + containing the length of the shortest and num_parts-1 the + length of the longest name; is a supplied buffer of + MAX_PATH+1 size +*/ static status_t compose_driver_names(device_node_info *node, const char *dir, const char *filename_pattern, int num_parts, @@ -454,12 +520,11 @@ } -/** notify all drivers under . If is true, notify all, - * if false, stop once a drivers notification function returned B_OK - * buffer - scratch buffer of size B_PATH_NAME_LENGTH + 1 ; destroyed on exit - * return: B_NAME_NOT_FOUND, if tell_all is false and no driver returned B_OK - */ - +/*! Notify all drivers under . If is true, notify all, + if false, stop once a drivers notification function returned B_OK + buffer - scratch buffer of size B_PATH_NAME_LENGTH + 1 ; destroyed on exit + return: B_NAME_NOT_FOUND, if tell_all is false and no driver returned B_OK +*/ static status_t try_drivers(device_node_info *node, char *directory, bool tell_all, char *buffer) @@ -511,12 +576,11 @@ } -/** find normal child of node that are stored under ; first, we - * look for a specific driver; if none could be found, find a generic - * one path, buffer - used as scratch buffer (all of size B_PATH_NAME_LENGTH + 1) - * return: B_NAME_NOT_FOUND if no consumer could be found - */ - +/*! Find normal child of node that are stored under ; first, we + look for a specific driver; if none could be found, find a generic + one path, buffer - used as scratch buffer (all of size B_PATH_NAME_LENGTH + 1) + return: B_NAME_NOT_FOUND if no consumer could be found +*/ static status_t find_normal_child(device_node_info *node, const char *dir, const char *filename_pattern, int num_parts, @@ -584,16 +648,15 @@ } -/** pre-process dynamic child name pattern. - * split into directory and pattern and count split positions; - * further, remove quotes from directory - * pattern - pattern of consumer name - * buffer - buffer to store results in - * (returned strings all point to !) - * filename_pattern - pattern of file name - * *num_parts - number of split positions - */ - +/*! Pre-process dynamic child name pattern. + split into directory and pattern and count split positions; + further, remove quotes from directory + pattern - pattern of consumer name + buffer - buffer to store results in + (returned strings all point to !) + filename_pattern - pattern of file name + *num_parts - number of split positions +*/ static status_t preprocess_child_names(const char *pattern, char *buffer, char **filename_pattern, int *const num_parts) @@ -660,11 +723,10 @@ } -/** find consumers for one given pattern - * has_normal_drivers - in: true - don't search for specific driver - * out: true - specific driver was found - */ - +/*! Find consumers for one given pattern + has_normal_drivers - in: true - don't search for specific driver + out: true - specific driver was found +*/ static status_t register_dynamic_child_device(device_node_info *node, const char *bus, const char *pattern, bool *has_normal_driver) @@ -738,14 +800,13 @@ } -/** Iterates over the given list and tries to load all drivers and modules - * in that list. - * The list is emptied and freed during the traversal. - * - * ToDo: Old style drivers will be initialized as well, new style driver - * handling is not yet done. - */ +/*! Iterates over the given list and tries to load all drivers and modules + in that list. + The list is emptied and freed during the traversal. + ToDo: Old style drivers will be initialized as well, new style driver + handling is not yet done. +*/ static status_t try_drivers(struct list &list, bool tryBusDrivers) { @@ -960,7 +1021,8 @@ static status_t -get_nodes_for_device_type(device_node_info *node, struct list *list, const char *type) +get_nodes_for_device_type(device_node_info *node, struct list *list, + const char *type) { bool matches = false; @@ -977,8 +1039,9 @@ if (!matches) { // we also accept any dump busses uint8 onDemand = false; - pnp_get_attr_uint8(node, B_DRIVER_FIND_DEVICES_ON_DEMAND, &onDemand, false); - + pnp_get_attr_uint8(node, B_DRIVER_FIND_DEVICES_ON_DEMAND, &onDemand, + false); + if (onDemand) matches = true; } @@ -1009,12 +1072,12 @@ // device manager private API -/** Register the device of a child for the \a node that might accept it. - * childName - module name of child/consumer - */ - +/*! Register the device of a child for the \a node that might accept it. + childName - module name of child/consumer +*/ status_t -dm_register_child_device(device_node_info *node, const char *childName, bool checkSupport) +dm_register_child_device(device_node_info *node, const char *childName, + bool checkSupport) { driver_module_info *child; status_t status; @@ -1057,11 +1120,10 @@ } -/** find and notify dynamic consumers that device was added - * errors returned by consumers aren't reported, only problems - * like malformed consumer patterns - */ - +/*! Find and notify dynamic consumers that device was added + errors returned by consumers aren't reported, only problems + like malformed consumer patterns +*/ status_t dm_register_dynamic_child_devices(device_node_info *node) { @@ -1143,11 +1205,10 @@ } -/** Register all fixed child devices of of the given \a node; in contrast - * to dynamic child devices, errors reported by fixed child devices are - * not ignored but returned, and regarded critical. - */ - +/*! Register all fixed child devices of of the given \a node; in contrast + to dynamic child devices, errors reported by fixed child devices are + not ignored but returned, and regarded critical. +*/ status_t dm_register_fixed_child_devices(device_node_info *node) { @@ -1236,9 +1297,13 @@ while (iterator.GetNext(path, stat) == B_OK) { if (S_ISDIR(stat.st_mode)) { + add_node_listener(stat.st_dev, stat.st_ino, B_WATCH_DIRECTORY, + sDirectoryWatcher); + // We need to make sure that drivers in ie. "audio/raw/" can // be found as well - therefore, we must make sure that "audio" // exists on /dev. + size_t length = strlen("drivers/dev"); if (strncmp(type, "drivers/dev", length)) continue; @@ -1274,7 +1339,8 @@ dprintf("bus: %s\n", path.Leaf()); while (busIterator.GetNext(path, stat) == B_OK) { - path_entry *entry = find_node_ref_in_list(&drivers, stat.st_dev, stat.st_ino); + path_entry *entry = find_node_ref_in_list(&drivers, stat.st_dev, + stat.st_ino); if (entry == NULL) continue; @@ -1310,7 +1376,20 @@ TRACE(("probe_for_device_type(type = %s)\n", type)); char deviceType[64]; - snprintf(deviceType, sizeof(deviceType), "drivers/dev%s%s", type[0] ? "/" : "", type); + snprintf(deviceType, sizeof(deviceType), "drivers/dev%s%s", + type[0] ? "/" : "", type); + if (!sWatching && gBootDevice > 0) { + // We're probing the actual boot volume for the first time, + // let's watch its driver directories for changes + + new(&sDirectoryWatcher) DirectoryWatcher; + for (uint32 i = 0; kModulePaths[i] != NULL; i++) { + start_watching(kModulePaths[i], "drivers/dev"); + start_watching(kModulePaths[i], "drivers/bin"); + } + sWatching = true; + } + return probe_for_driver_modules(deviceType); } Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-20 16:48:16 UTC (rev 24035) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-02-20 16:55:05 UTC (rev 24036) @@ -7,35 +7,37 @@ */ -#include "IOScheduler.h" +#include +#include +#include +#include +#include +#include + +#include #include -#include +#include #include -#include +#include +#include #include +#include +#include #include #include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include "IOScheduler.h" -#include -#include -#include -#include -#include - //#define TRACE_DEVFS #ifdef TRACE_DEVFS # define TRACE(x) dprintf x @@ -131,6 +133,8 @@ time_t last_modified; image_id image; uint32 devices_published; + uint32 devices_used; + bool binary_updated; // driver image information int32 *api_version; @@ -140,14 +144,24 @@ status_t (*uninit_hardware)(void); }; - struct node_path_entry : DoublyLinkedListLinkImpl { char path[B_PATH_NAME_LENGTH]; }; +class DriverWatcher : public NotificationListener { + public: + DriverWatcher(); + virtual ~DriverWatcher(); + virtual void EventOccured(NotificationService& service, + const KMessage* event); +}; + + static void get_device_name(struct devfs_vnode *vnode, char *buffer, size_t size); +static status_t unpublish_node(struct devfs *fs, devfs_vnode *node, + mode_t type); static status_t publish_device(struct devfs *fs, const char *path, device_node_info *deviceNode, pnp_devfs_driver_info *info, driver_entry *driver, device_hooks *ops, int32 apiVersion); @@ -156,6 +170,7 @@ /* the one and only allowed devfs instance */ static struct devfs *sDeviceFileSystem = NULL; static int32 sDefaultApiVersion = 1; +static DriverWatcher sDriverWatcher; // #pragma mark - driver private @@ -211,24 +226,25 @@ #error Add checks here for new vs old api version! #endif if (*driver->api_version > B_CUR_DRIVER_API_VERSION) { - dprintf("%s: api_version %ld not handled\n", driver->name, + dprintf("devfs: \"%s\" api_version %ld not handled\n", driver->name, *driver->api_version); status = B_BAD_VALUE; goto error1; } if (*driver->api_version < 1) { - dprintf("%s: api_version invalid\n", driver->name); + dprintf("devfs: \"%s\" api_version invalid\n", driver->name); status = B_BAD_VALUE; goto error1; } } else - dprintf("%s: api_version missing\n", driver->name); + dprintf("devfs: \"%s\" api_version missing\n", driver->name); if (get_image_symbol(image, "publish_devices", B_SYMBOL_TYPE_TEXT, (void **)&driver->publish_devices) != B_OK || get_image_symbol(image, "find_device", B_SYMBOL_TYPE_TEXT, (void **)&driver->find_device) != B_OK) { - dprintf("%s: mandatory driver symbol(s) missing!\n", driver->name); + dprintf("devfs: \"%s\" mandatory driver symbol(s) missing!\n", + driver->name); status = B_BAD_VALUE; goto error1; } @@ -238,8 +254,8 @@ if (get_image_symbol(image, "init_hardware", B_SYMBOL_TYPE_TEXT, (void **)&init_hardware) == B_OK && (status = init_hardware()) != B_OK) { - dprintf("%s: init_hardware() failed: %s\n", driver->name, - strerror(status)); + TRACE(("%s: init_hardware() failed: %s\n", driver->name, + strerror(status))); status = ENXIO; goto error1; } @@ -247,8 +263,8 @@ if (get_image_symbol(image, "init_driver", B_SYMBOL_TYPE_TEXT, (void **)&init_driver) == B_OK && (status = init_driver()) != B_OK) { - dprintf("%s: init_driver() failed: %s\n", driver->name, - strerror(status)); + TRACE(("%s: init_driver() failed: %s\n", driver->name, + strerror(status))); status = ENXIO; goto error2; } @@ -267,7 +283,7 @@ // we keep the driver loaded if it exports at least a single interface devicePaths = driver->publish_devices(); if (devicePaths == NULL) { - dprintf("%s: publish_devices() returned NULL.\n", driver->name); + TRACE(("%s: publish_devices() returned NULL.\n", driver->name)); status = ENXIO; goto error3; } @@ -327,6 +343,133 @@ } +/*! Collects all devices belonging to the \a driver and unpublishs them. +*/ +static void +unpublish_driver(driver_entry *driver) +{ + RecursiveLocker locker(&sDeviceFileSystem->lock); + + // Iterate through all nodes until all devices of this driver have + // been unpublished + + while (driver->devices_published > 0) { + struct hash_iterator i; + hash_open(sDeviceFileSystem->vnode_hash, &i); + + while (true) { + devfs_vnode *vnode = (devfs_vnode *)hash_next( + sDeviceFileSystem->vnode_hash, &i); + if (vnode == NULL) + break; + + if (S_ISCHR(vnode->stream.type) + && vnode->stream.u.dev.driver == driver) + unpublish_node(sDeviceFileSystem, vnode, S_IFCHR); + } + + hash_close(sDeviceFileSystem->vnode_hash, &i, false); + } +} + + +/*! Collects all published devices of a driver, compares them to what the + driver would publish now, and then publishes/unpublishes the devices + as needed. + If the driver does not publish any devices anymore, it is unloaded. +*/ +static status_t +republish_driver(driver_entry *driver) +{ + if (driver->image < 0) { + // The driver is not yet loaded - go through the normal load procedure + return load_driver(driver); + } + + RecursiveLocker locker(&sDeviceFileSystem->lock); + + // build the list of currently present devices of this driver + // by iterating through all present nodes + struct hash_iterator i; + hash_open(sDeviceFileSystem->vnode_hash, &i); + + DoublyLinkedList currentNodes; + while (true) { + devfs_vnode *vnode = (devfs_vnode *)hash_next( + sDeviceFileSystem->vnode_hash, &i); + if (vnode == NULL) + break; + + if (S_ISCHR(vnode->stream.type) + && vnode->stream.u.dev.driver == driver) { + node_path_entry *path = new(std::nothrow) node_path_entry; + if (!path) { + while ((path = currentNodes.RemoveHead())) + delete path; + hash_close(sDeviceFileSystem->vnode_hash, &i, false); + return B_NO_MEMORY; + } + + get_device_name(vnode, path->path, sizeof(path->path)); + currentNodes.Add(path); + } + } + hash_close(sDeviceFileSystem->vnode_hash, &i, false); + + // now ask the driver for it's currently published devices + const char **devicePaths = driver->publish_devices(); + + int32 exported = 0; + for (; devicePaths != NULL && devicePaths[0]; devicePaths++) { + bool present = false; + node_path_entry *entry = currentNodes.Head(); + while (entry) { + if (strncmp(entry->path, devicePaths[0], B_PATH_NAME_LENGTH) == 0) { + // this device was present before and still is -> no republish + currentNodes.Remove(entry); + delete entry; + exported++; + present = true; + break; + } + + entry = currentNodes.GetNext(entry); + } + + if (present) + continue; + + // the device was not present before -> publish it now + device_hooks *hooks = driver->find_device(devicePaths[0]); + if (hooks == NULL) + continue; + + TRACE(("devfs: publishing new device \"%s\"\n", devicePaths[0])); + if (publish_device(sDeviceFileSystem, devicePaths[0], NULL, NULL, + driver, hooks, *driver->api_version) == B_OK) + exported++; + } + + // what's left in currentNodes was present but is not anymore -> unpublish + node_path_entry *entry = currentNodes.Head(); + while (entry) { + TRACE(("devfs: unpublishing no more present \"%s\"\n", entry->path)); + devfs_unpublish_device(entry->path, true); + node_path_entry *next = currentNodes.GetNext(entry); + currentNodes.Remove(entry); + delete entry; + entry = next; + } + + if (exported == 0) { + TRACE(("devfs: driver \"%s\" does not publish any more nodes and is unloaded\n", driver->path)); + unload_driver(driver); + } + + return B_OK; +} + + static const char * get_leaf(const char *path) { @@ -338,6 +481,25 @@ } +static driver_entry * +find_driver(dev_t device, ino_t node) +{ + hash_iterator iterator; + hash_open(sDeviceFileSystem->driver_hash, &iterator); + driver_entry *driver; + while (true) { + driver = (driver_entry *)hash_next(sDeviceFileSystem->driver_hash, + &iterator); + if (driver == NULL + || driver->device == device && driver->node == node) + break; + } + + hash_close(sDeviceFileSystem->driver_hash, &iterator, false); + return driver; +} + + static status_t add_driver(const char *path, image_id image) { @@ -361,6 +523,8 @@ sDeviceFileSystem->driver_hash, get_leaf(path)); if (driver != NULL) { // we know this driver + // TODO: check if this driver is a different one and has precendence + // (ie. common supersedes system). // TODO: test for changes here and/or via node monitoring and reload // the driver if necessary if (driver->image < B_OK) @@ -386,6 +550,9 @@ driver->node = stat.st_ino; driver->image = image; driver->last_modified = stat.st_mtime; + driver->devices_published = 0; + driver->devices_used = 0; + driver->binary_updated = false; driver->api_version = NULL; driver->find_device = NULL; @@ -394,6 +561,8 @@ driver->uninit_hardware = NULL; hash_insert(sDeviceFileSystem->driver_hash, driver); + if (stat.st_dev > 0) + add_node_listener(stat.st_dev, stat.st_ino, B_WATCH_STAT, sDriverWatcher); // Even if loading the driver fails - its entry will stay with us // so that we don't have to go through it again @@ -446,6 +615,51 @@ } +// #pragma mark - DriverWatcher + + +DriverWatcher::DriverWatcher() +{ +} + + +DriverWatcher::~DriverWatcher() +{ +} + + +void +DriverWatcher::EventOccured(NotificationService& service, + const KMessage* event) +{ + if (event->GetInt32("opcode", -1) != B_STAT_CHANGED + || (event->GetInt32("fields", 0) & B_STAT_MODIFICATION_TIME) == 0) + return; + + RecursiveLocker locker(&sDeviceFileSystem->lock); + + driver_entry *driver = find_driver(event->GetInt32("device", -1), + event->GetInt64("node", 0)); + if (driver == NULL) + return; + + if (driver->devices_used == 0) { + // reload driver + dprintf("devfs: reload driver \"%s\"\n", driver->name); + //unpublish_driver(driver); + // TODO: even though we would need to unpublish the driver, this + // doesn't work right now from here (dead lock in the node monitor + // notifications) + unload_driver(driver); + load_driver(driver); + } else { + // driver is in use right now, only mark it to be updated when possible + dprintf("devfs: changed driver \"%s\" is still in use\n", driver->name); + driver->binary_updated = true; + } +} + + // #pragma mark - devfs private @@ -1028,105 +1242,6 @@ } -/*! Collects all published devices of a driver, compares them to what the - driver would publish now, and then publishes/unpublishes the devices - as needed. - If the driver does not publish any devices anymore, it is unloaded. -*/ -static status_t -republish_driver(driver_entry *driver) -{ - if (driver->image < 0) { - // The driver is not yet loaded - go through the normal load procedure - return load_driver(driver); - } - - RecursiveLocker locker(&sDeviceFileSystem->lock); - - // build the list of currently present devices of this driver - // by iterating through all present nodes - struct hash_iterator i; - hash_open(sDeviceFileSystem->vnode_hash, &i); - - DoublyLinkedList currentNodes; - while (true) { - devfs_vnode *vnode = (devfs_vnode *)hash_next( - sDeviceFileSystem->vnode_hash, &i); - if (vnode == NULL) - break; - - if (S_ISCHR(vnode->stream.type) - && vnode->stream.u.dev.driver == driver) { - node_path_entry *path = new(std::nothrow) node_path_entry; - if (!path) { - while ((path = currentNodes.RemoveHead())) - delete path; - hash_close(sDeviceFileSystem->vnode_hash, &i, false); - return B_NO_MEMORY; - } - - get_device_name(vnode, path->path, sizeof(path->path)); - currentNodes.Add(path); - } - - vnode = (devfs_vnode *)hash_next(sDeviceFileSystem->vnode_hash, &i); - } - hash_close(sDeviceFileSystem->vnode_hash, &i, false); - - // now ask the driver for it's currently published devices - const char **devicePaths = driver->publish_devices(); - - int32 exported = 0; - for (; devicePaths != NULL && devicePaths[0]; devicePaths++) { - bool present = false; - node_path_entry *entry = currentNodes.Head(); - while (entry) { - if (strncmp(entry->path, devicePaths[0], B_PATH_NAME_LENGTH) == 0) { - // this device was present before and still is -> no republish - currentNodes.Remove(entry); - delete entry; - exported++; - present = true; - break; - } - - entry = currentNodes.GetNext(entry); - } - - if (present) - continue; - - // the device was not present before -> publish it now - device_hooks *hooks = driver->find_device(devicePaths[0]); - if (hooks == NULL) - continue; - - TRACE(("devfs: publishing new device \"%s\"\n", devicePaths[0])); - if (publish_device(sDeviceFileSystem, devicePaths[0], NULL, NULL, - driver, hooks, *driver->api_version) == B_OK) - exported++; - } - - // what's left in currentNodes was present but is not anymore -> unpublish - node_path_entry *entry = currentNodes.Head(); - while (entry) { - TRACE(("devfs: unpublishing no more present \"%s\"\n", entry->path)); - devfs_unpublish_device(entry->path, true); - node_path_entry *next = currentNodes.GetNext(entry); - currentNodes.Remove(entry); - delete entry; - entry = next; - } - - if (exported == 0) { - TRACE(("devfs: driver \"%s\" does not publish any more nodes and is unloaded\n", driver->path)); - unload_driver(driver); - } - - return B_OK; -} - - /** Construct complete device name (as used for device_open()). * This is safe to use only when the device is in use (and therefore * cannot be unpublished during the iteration). @@ -1200,7 +1315,7 @@ TRACE(("devfs_mount: entry\n")); if (sDeviceFileSystem) { - dprintf("double mount of devfs attempted\n"); + TRACE(("double mount of devfs attempted\n")); err = B_ERROR; goto err; } @@ -1233,6 +1348,8 @@ goto err3; } + new(&sDriverWatcher) DriverWatcher; + [... truncated: 53 lines follow ...] From oruizdorantes at mail.berlios.de Wed Feb 20 22:06:00 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Wed, 20 Feb 2008 22:06:00 +0100 Subject: [Haiku-commits] r24037 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802202106.m1KL60xo010937@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-20 22:05:59 +0100 (Wed, 20 Feb 2008) New Revision: 24037 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24037&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c Log: Add handling to retrieve the id assigned by the stack Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-20 16:55:05 UTC (rev 24036) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-02-20 21:05:59 UTC (rev 24037) @@ -494,6 +494,7 @@ *cookie = bdev; release_sem(bdev->lock); + flowf(" successful\n"); return B_OK; unrun: @@ -624,6 +625,12 @@ memcpy(params, &bdev->stat, sizeof(bt_hci_statistics)); err = B_OK; break; + + case GET_HCI_ID: + *(hci_id*)params = bdev->hdev; + err = bdev->hdev + 15; + break; + default: debugf("Invalid opcode %ld.\n", msg); From oruizdorantes at mail.berlios.de Wed Feb 20 22:10:53 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Wed, 20 Feb 2008 22:10:53 +0100 Subject: [Haiku-commits] r24038 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200802202110.m1KLAr5k011902@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-20 22:10:53 +0100 (Wed, 20 Feb 2008) New Revision: 24038 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24038&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h Log: Lesson learned, dont use system IOCTL codes Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-20 21:05:59 UTC (rev 24037) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-02-20 21:10:53 UTC (rev 24038) @@ -11,8 +11,8 @@ #include #include +#include - typedef enum { ANCILLYANT = 1, RUNNING, LEAVING, @@ -78,12 +78,17 @@ #define BT_WILL_NEED_A_RESET (1<<2) #define BT_DIGIANSWER (1<<4) -/* IOCTLS */ -#define ISSUE_BT_COMMAND (1<<0) -#define GET_STATICS (1<<1) -#define GET_NOTIFICATION_PORT (1<<2) -#define GET_HCI_ID (1<<3) +/* Mandatory IOCTLS to be */ +#define BT_IOCTLS_OFFSET 3000 + +enum { + ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET , + GET_STATICS, + GET_NOTIFICATION_PORT, + GET_HCI_ID +}; + #define PACK_PORTCODE(type,hid,data) ((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF)) #define GET_PORTCODE_TYPE(code) ((code&0xFF000000)>>24) #define GET_PORTCODE_HID(code) ((code&0x00FF0000)>>16) From bonefish at mail.berlios.de Thu Feb 21 01:18:35 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 21 Feb 2008 01:18:35 +0100 Subject: [Haiku-commits] r24040 - haiku/trunk/src/system/libroot/posix/unistd Message-ID: <200802210018.m1L0IZRQ001552@sheep.berlios.de> Author: bonefish Date: 2008-02-21 01:18:35 +0100 (Thu, 21 Feb 2008) New Revision: 24040 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24040&view=rev Modified: haiku/trunk/src/system/libroot/posix/unistd/process.c Log: * setpgid() is not supposed to return the group ID. It shall return 0 on success. * setpgrp() is not supposed to fail (could happen, if the calling process was a session leader). Modified: haiku/trunk/src/system/libroot/posix/unistd/process.c =================================================================== --- haiku/trunk/src/system/libroot/posix/unistd/process.c 2008-02-21 00:08:03 UTC (rev 24039) +++ haiku/trunk/src/system/libroot/posix/unistd/process.c 2008-02-21 00:18:35 UTC (rev 24040) @@ -67,16 +67,21 @@ int setpgid(pid_t process, pid_t group) { - status_t status = _kern_setpgid(process, group); + pid_t result = _kern_setpgid(process, group); + if (result >= 0) + return 0; - RETURN_AND_SET_ERRNO(status); + RETURN_AND_SET_ERRNO(result); } pid_t setpgrp(void) { - return setpgid(0, 0); + // setpgrp() never fails -- setpgid() fails when the process is a session + // leader, though. + pid_t result = _kern_setpgid(0, 0); + return result >= 0 ? result : getpgrp(); } From simontaylor1 at ntlworld.com Thu Feb 21 01:19:50 2008 From: simontaylor1 at ntlworld.com (Simon Taylor) Date: Thu, 21 Feb 2008 00:19:50 +0000 Subject: [Haiku-commits] r24006 - haiku/trunk/src/kits/interface In-Reply-To: <894b9700802181228q77f3c8e2t9f09cc24c25e8c23@mail.gmail.com> References: <1234440206-BeMail@kirilla> <894b9700802181228q77f3c8e2t9f09cc24c25e8c23@mail.gmail.com> Message-ID: <47BCC3A6.3040500@ntlworld.com> Stefano Ceccherini wrote: > 2008/2/18, Jonas Sundstr?m : >> Did this change break toggling the menus? >> (Click to open, and then - if you so desire - >> just click again to close it.) > > Could be. > >> I'm not sure I like the new behavior in Deskbar. >> With Deskbar in the top-right corner, moving the >> pointer from an application's entry to its Close All >> is likely to pass the application entry below it and >> replace the menu you were moving towards. > > I'm a bit dubious too. > Let's see if we can get used. That doesn't sound good to me. I haven't played with a revision with this change yet - but menus are supposed to have something whereby once the submenu has appeared you can keep moving towards it (even passing over other items in the "parent" menu) and the same menu will stay open. It makes menus much easier to navigate, requiring much less tight mouse work not to leave the correct part of the parent menu - it's pretty vital to me that this works properly. Sorry if I misread Jonas's description of the new behaviour. Simon > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > From axeld at mail.berlios.de Thu Feb 21 01:08:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 21 Feb 2008 01:08:03 +0100 Subject: [Haiku-commits] r24039 - haiku/trunk/headers/posix Message-ID: <200802210008.m1L083c6020508@sheep.berlios.de> Author: axeld Date: 2008-02-21 01:08:03 +0100 (Thu, 21 Feb 2008) New Revision: 24039 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24039&view=rev Modified: haiku/trunk/headers/posix/inttypes.h Log: Added printf()/scanf() type definitions, courtesy of Curtis Wanner - thanks a lot! Modified: haiku/trunk/headers/posix/inttypes.h =================================================================== --- haiku/trunk/headers/posix/inttypes.h 2008-02-20 21:10:53 UTC (rev 24038) +++ haiku/trunk/headers/posix/inttypes.h 2008-02-21 00:08:03 UTC (rev 24039) @@ -1,8 +1,9 @@ +/* + * Copyright 2002-2008 Haiku inc. All rights reserved. + * Distributed under the terms of the MIT License + */ #ifndef _INTTYPES_H_ #define _INTTYPES_H_ -/* -** Distributed under the terms of the OpenBeOS License. -*/ #include @@ -13,7 +14,187 @@ intmax_t rem; /* remainder */ } imaxdiv_t; +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) +/* fprintf() macros for signed integers */ +# define PRId8 "d" +# define PRIdLEAST8 "d" +# define PRIdFAST8 "d" +# define PRIi8 "i" +# define PRIiLEAST8 "i" +# define PRIiFAST8 "i" +# define PRId16 "d" +# define PRIdLEAST16 "d" +# define PRIdFAST16 "d" +# define PRIi16 "i" +# define PRIiLEAST16 "i" +# define PRIiFAST16 "i" + +# define PRId32 "d" +# define PRIdLEAST32 "d" +# define PRIdFAST32 "d" +# define PRIi32 "i" +# define PRIiLEAST32 "i" +# define PRIiFAST32 "i" + +# define PRId64 "lld" +# define PRIdLEAST64 "lld" +# define PRIdFAST64 "lld" +# define PRIi64 "lli" +# define PRIiLEAST64 "lli" +# define PRIiFAST64 "lli" + +# define PRIdMAX "lld" +# define PRIdPTR "d" +# define PRIiMAX "lli" +# define PRIiPTR "i" + +/* fprintf() macros for unsigned integers */ +# define PRIu8 "u" +# define PRIuLEAST8 "u" +# define PRIuFAST8 "u" +# define PRIo8 "o" +# define PRIoLEAST8 "o" +# define PRIoFAST8 "o" +# define PRIx8 "x" +# define PRIxLEAST8 "x" +# define PRIxFAST8 "x" +# define PRIX8 "X" +# define PRIXLEAST8 "X" +# define PRIXFAST8 "X" + +# define PRIu16 "u" +# define PRIuLEAST16 "u" +# define PRIuFAST16 "u" +# define PRIo16 "o" +# define PRIoLEAST16 "o" +# define PRIoFAST16 "o" +# define PRIx16 "x" +# define PRIxLEAST16 "x" +# define PRIxFAST16 "x" +# define PRIX16 "X" +# define PRIXLEAST16 "X" +# define PRIXFAST16 "X" + +# define PRIu32 "u" +# define PRIuLEAST32 "u" +# define PRIuFAST32 "u" +# define PRIo32 "o" +# define PRIoLEAST32 "o" +# define PRIoFAST32 "o" +# define PRIx32 "x" +# define PRIxLEAST32 "x" +# define PRIxFAST32 "x" +# define PRIX32 "X" +# define PRIXLEAST32 "X" +# define PRIXFAST32 "X" + +# define PRIu64 "llu" +# define PRIuLEAST64 "llu" +# define PRIuFAST64 "llu" +# define PRIo64 "llo" +# define PRIoLEAST64 "llo" +# define PRIoFAST64 "llo" +# define PRIx64 "llx" +# define PRIxLEAST64 "llx" +# define PRIxFAST64 "llx" +# define PRIX64 "llX" +# define PRIXLEAST64 "llX" +# define PRIXFAST64 "llX" + +# define PRIuMAX "llu" +# define PRIuPTR "u" +# define PRIoMAX "llo" +# define PRIoPTR "o" +# define PRIxMAX "llx" +# define PRIxPTR "x" +# define PRIXMAX "llX" +# define PRIXPTR "X" + +/* fscanf() macros for signed integers */ +# define SCNd8 "hhd" +# define SCNdLEAST8 "hhd" +# define SCNdFAST8 "d" +# define SCNi8 "hhi" +# define SCNiLEAST8 "hhi" +# define SCNiFAST8 "i" + +# define SCNd16 "hd" +# define SCNdLEAST16 "hd" +# define SCNdFAST16 "d" +# define SCNi16 "hi" +# define SCNiLEAST16 "hi" +# define SCNiFAST16 "i" + +# define SCNd32 "d" +# define SCNdLEAST32 "d" +# define SCNdFAST32 "d" +# define SCNi32 "i" +# define SCNiLEAST32 "i" +# define SCNiFAST32 "i" + +# define SCNd64 "lld" +# define SCNdLEAST64 "lld" +# define SCNdFAST64 "lld" +# define SCNi64 "lli" +# define SCNiLEAST64 "lli" +# define SCNiFAST64 "lli" + +# define SCNdMAX "lld" +# define SCNdPTR "d" +# define SCNiMAX "lli" +# define SCNiPTR "i" + +/* fscanf() macros for unsigned integers */ +# define SCNu8 "hhu" +# define SCNuLEAST8 "hhu" +# define SCNuFAST8 "u" +# define SCNo8 "hho" +# define SCNoLEAST8 "hho" +# define SCNoFAST8 "o" +# define SCNx8 "hhx" +# define SCNxLEAST8 "hhx" +# define SCNxFAST8 "x" + +# define SCNu16 "hu" +# define SCNuLEAST16 "hu" +# define SCNuFAST16 "u" +# define SCNo16 "ho" +# define SCNoLEAST16 "ho" +# define SCNoFAST16 "o" +# define SCNx16 "hx" +# define SCNxLEAST16 "hx" +# define SCNxFAST16 "x" + +# define SCNu32 "u" +# define SCNuLEAST32 "u" +# define SCNuFAST32 "u" +# define SCNo32 "o" +# define SCNoLEAST32 "o" +# define SCNoFAST32 "o" +# define SCNx32 "x" +# define SCNxLEAST32 "x" +# define SCNxFAST32 "x" + +# define SCNu64 "llu" +# define SCNuLEAST64 "llu" +# define SCNuFAST64 "llu" +# define SCNo64 "llo" +# define SCNoLEAST64 "llo" +# define SCNoFAST64 "llo" +# define SCNx64 "llx" +# define SCNxLEAST64 "llx" +# define SCNxFAST64 "llx" + +# define SCNuMAX "llu" +# define SCNuPTR "u" +# define SCNoMAX "llo" +# define SCNoPTR "o" +# define SCNxMAX "llx" +# define SCNxPTR "x" +#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ + + #ifdef __cplusplus extern "C" { #endif From bonefish at mail.berlios.de Thu Feb 21 02:00:15 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 21 Feb 2008 02:00:15 +0100 Subject: [Haiku-commits] r24042 - haiku/trunk/src/system/kernel Message-ID: <200802210100.m1L10FdJ030282@sheep.berlios.de> Author: bonefish Date: 2008-02-21 02:00:14 +0100 (Thu, 21 Feb 2008) New Revision: 24042 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24042&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: Added TODO: Process groups should live on until the process is reaped. Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-02-21 00:46:22 UTC (rev 24041) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-02-21 01:00:14 UTC (rev 24042) @@ -1323,6 +1323,14 @@ // delete the team if we're its main thread if (deleteTeam) { + // TODO: Deleting the process group is actually a problem. According to + // the POSIX standard the process should become a zombie and live on + // until it is reaped. Hence the process group would continue to exist + // for that time as well. That is moving processes to it (setpgid()) + // should work. This can actually happen e.g. when executing something + // like "echo foobar | wc" in the shell. The built-in "echo" could + // exit() even before setpgid() has been invoked for the "wc" child. + // Cf. bug #1799. team_delete_process_group(freeGroup); team_delete_team(team); From bonefish at mail.berlios.de Thu Feb 21 02:01:02 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 21 Feb 2008 02:01:02 +0100 Subject: [Haiku-commits] r24043 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200802210101.m1L112fw030424@sheep.berlios.de> Author: bonefish Date: 2008-02-21 02:01:02 +0100 (Thu, 21 Feb 2008) New Revision: 24043 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24043&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/setpgid_test.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: Added small setpgid() test. Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-02-21 01:00:14 UTC (rev 24042) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-02-21 01:01:02 UTC (rev 24043) @@ -14,6 +14,8 @@ : signal_test.cpp ; +SimpleTest setpgid_test : setpgid_test.cpp ; + SimpleTest setjmp_test : setjmp_test.c ; Added: haiku/trunk/src/tests/system/libroot/posix/setpgid_test.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/setpgid_test.cpp 2008-02-21 01:00:14 UTC (rev 24042) +++ haiku/trunk/src/tests/system/libroot/posix/setpgid_test.cpp 2008-02-21 01:01:02 UTC (rev 24043) @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include + + +int +main() +{ + pid_t parentPID = getpid(); + printf("parent pid: %d\n", parentPID); + printf("parent pgid: %d\n", getpgrp()); + + pid_t childPID = fork(); + if (childPID < 0) { + fprintf(stderr, "fork() failed: %s\n", strerror(errno)); + exit(1); + } else if (childPID == 0) { + // child + childPID = getpid(); + printf("child pid: %d, pgid: %d\n", childPID, getpgrp()); + + printf("child setpgid(0, 0)\n"); + if (setpgid(0, 0) < 0) { + fprintf(stderr, "child: first setpgid() failed: %s\n", strerror(errno)); + exit(1); + } +// printf("child setsid()\n"); +// if (setsid() < 0) { +// fprintf(stderr, "child: setsid() failed: %s\n", strerror(errno)); +// exit(1); +// } + + printf("child pgid: %d\n", getpgrp()); + + pid_t grandChildPID = fork(); + if (grandChildPID < 0) { + fprintf(stderr, "fork() 2 failed: %s\n", strerror(errno)); + exit(1); + } else if (grandChildPID == 0) { + // grand child + grandChildPID = getpid(); + printf("gchild pid: %d, pgid: %d\n", grandChildPID, getpgrp()); + sleep(2); + printf("gchild pid: %d, pgid: %d\n", grandChildPID, getpgrp()); + } else { + // child + sleep(1); + + printf("child setpgid(0, %d)\n", parentPID); + if (setpgid(0, parentPID) < 0) { +// printf("child setpgid(0, 0)\n"); +// if (setpgid(0, 0) < 0) { + fprintf(stderr, "child: second setpgid() failed: %s\n", strerror(errno)); + exit(1); + } + + printf("child pgid: %d\n", getpgrp()); + } + + } else { + // parent + sleep(3); + } + + return 0; +} From bonefish at mail.berlios.de Thu Feb 21 01:46:23 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 21 Feb 2008 01:46:23 +0100 Subject: [Haiku-commits] r24041 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200802210046.m1L0kNg9028110@sheep.berlios.de> Author: bonefish Date: 2008-02-21 01:46:22 +0100 (Thu, 21 Feb 2008) New Revision: 24041 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24041&view=rev Modified: haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/team.cpp Log: * Removed unused team::pending_signals. * Added team::flags. Currently only used for setting a flag when a team has exec()ed. * Some improvements of _user_setpgid(): - It failed incorrectly when the target process was a process group leader. According to the standard it shall fail when the process is a session leader. Moving a process group leader to another process group is fine, even if that leaves the group leaderless. - Fixed race conditions. We need to recheck the error conditions when we hold the team spinlock. Otherwise the situation could change while we allocated the new process group. This was one of the reasons for bug #1799 -- after the shell fork()'s both parent and child invoke setpgid() for the child. - Fixed behavior for pid == pgid. It doesn't necessarily mean that a new group has to be created. - Fixed update of target process group orphaned state. - Squashed TODO: setpgid() on a child is supposed to fail after the child has exec()ed. Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-02-21 00:18:35 UTC (rev 24040) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-02-21 00:46:22 UTC (rev 24041) @@ -41,6 +41,8 @@ TEAM_STATE_DEATH // being killed }; +#define TEAM_FLAG_EXEC_DONE 0x01 + typedef enum job_control_state { JOB_CONTROL_STATE_NONE, JOB_CONTROL_STATE_STOPPED, @@ -155,7 +157,7 @@ char args[64]; // contents for the team_info::args field int num_threads; // number of threads in this team int state; // current team state, see above - int pending_signals; + int32 flags; void *io_context; sem_id death_sem; // semaphore to wait on for dying threads struct list dead_threads; Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-02-21 00:18:35 UTC (rev 24040) +++ haiku/trunk/src/system/kernel/team.cpp 2008-02-21 00:46:22 UTC (rev 24041) @@ -295,7 +295,7 @@ kprintf("children: %p\n", team->children); kprintf("num_threads: %d\n", team->num_threads); kprintf("state: %d\n", team->state); - kprintf("pending_signals: %#x\n", team->pending_signals); + kprintf("flags: 0x%lx\n", team->flags); kprintf("io_context: %p\n", team->io_context); if (team->address_space) kprintf("address_space: %p\n", team->address_space); @@ -607,6 +607,13 @@ static bool +is_session_leader(struct team *team) +{ + return team->session_id == team->id; +} + + +static bool is_process_group_leader(struct team *team) { return team->group_id == team->id; @@ -769,7 +776,7 @@ team->main_thread = NULL; team->loading_info = NULL; team->state = TEAM_STATE_BIRTH; - team->pending_signals = 0; + team->flags = 0; team->death_sem = -1; team->dead_threads_kernel_time = 0; @@ -1321,6 +1328,8 @@ threadName = path; rename_thread(thread_get_current_thread_id(), threadName); + atomic_or(&team->flags, TEAM_FLAG_EXEC_DONE); + status = team_create_thread_start(teamArgs); // this one usually doesn't return... @@ -2805,7 +2814,6 @@ struct thread *thread = thread_get_current_thread(); struct team *currentTeam = thread->team; struct team *team; - team_id teamID = -1; if (groupID < 0) return B_BAD_VALUE; @@ -2813,102 +2821,114 @@ if (processID == 0) processID = currentTeam->id; + // if the group ID is not specified, use the target process' ID + if (groupID == 0) + groupID = processID; + if (processID == currentTeam->id) { // we set our own group - teamID = currentTeam->id; - // we must not change our process group ID if we're a group leader - if (is_process_group_leader(currentTeam)) { - // if the group ID was not specified, we just return the - // process ID as we already are a process group leader - if (groupID == 0 || groupID == processID) - return processID; - + // we must not change our process group ID if we're a session leader + if (is_session_leader(currentTeam)) return B_NOT_ALLOWED; - } } else { - InterruptsSpinLocker _(thread_spinlock); + // another team is the target of the call -- check it out + InterruptsSpinLocker _(team_spinlock); - thread = thread_get_thread_struct_locked(processID); + team = team_get_team_struct_locked(processID); + if (team == NULL) + return ESRCH; - // the thread must be the team's main thread, as that - // determines its process ID - if (thread == NULL || thread != thread->team->main_thread) - return B_BAD_THREAD_ID; - - // check if the thread is in a child team of the calling team and - // if it's already a process group leader and in the same session - if (thread->team->parent != currentTeam - || is_process_group_leader(thread->team) - || thread->team->session_id != currentTeam->session_id) { + // The team must be a child of the calling team and in the same session. + // (If that's the case it isn't a session leader either.) + if (team->parent != currentTeam + || team->session_id != currentTeam->session_id) { return B_NOT_ALLOWED; } - // TODO: According to the standard, the call is also supposed to fail - // on a child, when the child already has executed exec*(). + if (team->group_id == groupID) + return groupID; - teamID = thread->team->id; + // The call is also supposed to fail on a child, when the child already + // has executed exec*() [EACCES]. + if ((team->flags & TEAM_FLAG_EXEC_DONE) != 0) + return EACCES; } - // if the group ID is not specified, a new group should be created - if (groupID == 0) - groupID = processID; - struct process_group *group = NULL; if (groupID == processID) { - // We need to create a new process group for this team + // A new process group might be needed. group = create_process_group(groupID); if (group == NULL) return B_NO_MEMORY; - // The team has a parent in the same session, but in another process - // group, so the new group won't be orphaned. - group->orphaned = false; + // Assume orphaned. We consider the situation of the team's parent + // below. + group->orphaned = true; } status_t status = B_OK; struct process_group *freeGroup = NULL; + struct process_group *freeGroup2 = NULL; InterruptsSpinLocker locker(team_spinlock); - team = team_get_team_struct_locked(teamID); + team = team_get_team_struct_locked(processID); if (team != NULL) { - if (processID == groupID) { - // we created a new process group, let us insert it into the team's - // session - insert_group_into_session(team->group->session, group); - remove_team_from_group(team, &freeGroup); - insert_team_into_group(group, team); + // check the conditions again -- they might have changed in the meantime + if (is_session_leader(team) + || team->session_id != currentTeam->session_id) { + status = B_NOT_ALLOWED; + } else if (team != currentTeam + && (team->flags & TEAM_FLAG_EXEC_DONE) != 0) { + status = EACCES; + } else if (team->group_id == groupID) { + // the team is already in the desired process group + freeGroup = group; } else { - // check if this team can have the group ID; there must be one - // matching process ID in the team's session + // Check if a process group with the requested ID already exists. + struct process_group *targetGroup + = team_get_process_group_locked(team->group->session, groupID); + if (targetGroup != NULL) { + // In case of processID == groupID we have to free the + // allocated group. + freeGroup2 = group; + } else if (processID == groupID) { + // We created a new process group, let us insert it into the + // team's session. + insert_group_into_session(team->group->session, group); + targetGroup = group; + } - struct process_group *targetGroup = - team_get_process_group_locked(team->group->session, groupID); if (targetGroup != NULL) { + // we got a group, let's move the team there process_group* oldGroup = team->group; - if (targetGroup != oldGroup) { - // we got a group, let's move the team there - remove_team_from_group(team, &freeGroup); - insert_team_into_group(targetGroup, team); - // Update the "orphaned" flag of all potentially affected - // groups. + remove_team_from_group(team, &freeGroup); + insert_team_into_group(targetGroup, team); - // the team's old group - if (oldGroup->teams != NULL) { - oldGroup->orphaned = false; - update_orphaned_process_group(oldGroup, -1); - } + // Update the "orphaned" flag of all potentially affected + // groups. - // children's groups - struct team* child = team->children; - while (child != NULL) { - child->group->orphaned = false; - update_orphaned_process_group(child->group, -1); + // the team's old group + if (oldGroup->teams != NULL) { + oldGroup->orphaned = false; + update_orphaned_process_group(oldGroup, -1); + } - child = child->siblings_next; - } + // the team's new group + struct team* parent = team->parent; + targetGroup->orphaned &= parent == NULL + || parent->group == targetGroup + || team->parent->session_id != team->session_id; + + // children's groups + struct team* child = team->children; + while (child != NULL) { + child->group->orphaned = false; + update_orphaned_process_group(child->group, -1); + + child = child->siblings_next; } } else status = B_NOT_ALLOWED; @@ -2926,12 +2946,13 @@ locker.Unlock(); - if (status != B_OK && group != NULL) { + if (status != B_OK) { // in case of error, the group hasn't been added into the hash team_delete_process_group(group); } team_delete_process_group(freeGroup); + team_delete_process_group(freeGroup2); return status == B_OK ? groupID : status; } From jackburton at mail.berlios.de Thu Feb 21 11:10:18 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 21 Feb 2008 11:10:18 +0100 Subject: [Haiku-commits] r24044 - haiku/trunk/src/kits/interface Message-ID: <200802211010.m1LAAI9a026322@sheep.berlios.de> Author: jackburton Date: 2008-02-21 11:10:17 +0100 (Thu, 21 Feb 2008) New Revision: 24044 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24044&view=rev Modified: haiku/trunk/src/kits/interface/Menu.cpp Log: Change the order we use to check the position of the mouse pointer inside menus: first sub, then current, then super. It's more logical, and handles every case (hopefully I've tested every possible combination) of overlapping menus correctly. Fixes bug #1821. Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2008-02-21 01:01:02 UTC (rev 24043) +++ haiku/trunk/src/kits/interface/Menu.cpp 2008-02-21 10:10:17 UTC (rev 24044) @@ -1424,13 +1424,14 @@ continue; } + // The order of the checks is important + // to be able to handle overlapping menus: + // first we check if mouse is inside a submenu, + // then if the menu is inside this menu, + // then if it's over a super menu. + bool overSub = _OverSubmenu(fSelected, screenLocation); item = _HitTestItems(location, B_ORIGIN); - if (item != NULL) { - _UpdateStateOpenSelect(item, openTime, mouseSpeed); - if (!releasedOnce) - releasedOnce = true; - - } else if (_OverSubmenu(fSelected, screenLocation)) { + if (overSub) { // Since the submenu has its own looper, // we can unlock ours. Doing so also make sure // that our window gets any update message to @@ -1450,11 +1451,15 @@ fState = MENU_STATE_CLOSED; } if (!LockLooper()) - break; + break; + } else if (item != NULL) { + _UpdateStateOpenSelect(item, openTime, mouseSpeed); + if (!releasedOnce) + releasedOnce = true; } else if (_OverSuper(screenLocation)) { fState = MENU_STATE_TRACKING; UnlockLooper(); - break; + break; } else { // Mouse pointer outside menu: // If there's no other submenu opened, @@ -1489,12 +1494,6 @@ UnlockLooper(); } -#if 1 - // TODO: on vmware, looks like the second system_time() could return - // a value smaller than the first call. Bug in VMWare or haiku ? - if (newPollTime <= pollTime) - newPollTime = pollTime + 5000; -#endif // mouseSpeed in px per ms // (actually point_distance returns the square of the distance, // so it's more px^2 per ms) @@ -2040,7 +2039,7 @@ if (subMenu == NULL || subMenu->Window() == NULL) return false; - // we assume that loc is in screen coords + // we assume that loc is in screen coords { if (subMenu->Window()->Frame().Contains(loc)) return true; From axeld at mail.berlios.de Thu Feb 21 14:19:54 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 21 Feb 2008 14:19:54 +0100 Subject: [Haiku-commits] r24045 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200802211319.m1LDJsKw032525@sheep.berlios.de> Author: axeld Date: 2008-02-21 14:19:54 +0100 (Thu, 21 Feb 2008) New Revision: 24045 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24045&view=rev Modified: haiku/trunk/headers/private/kernel/ksignal.h haiku/trunk/src/system/kernel/signal.cpp haiku/trunk/src/system/kernel/thread.cpp Log: * Added SIGNAL_FLAG_DONT_RESTART_SYSCALL for send_signal_etc() which utilizes the THREAD_FLAG_DONT_RESTART_SYSCALL (but only in SIGCONT for now). * resume_thread() is now using that flag to be compatible with BeOS. * This fixes the Terminal hanging on close. Modified: haiku/trunk/headers/private/kernel/ksignal.h =================================================================== --- haiku/trunk/headers/private/kernel/ksignal.h 2008-02-21 10:10:17 UTC (rev 24044) +++ haiku/trunk/headers/private/kernel/ksignal.h 2008-02-21 13:19:54 UTC (rev 24045) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_SIGNAL_H @@ -15,8 +15,9 @@ #define SIGNAL_TO_MASK(signal) (1LL << (signal - 1)) // additional send_signal_etc() flag -#define SIGNAL_FLAG_TEAMS_LOCKED (0x10000) +#define SIGNAL_FLAG_TEAMS_LOCKED (0x10000) // interrupts are disabled and team lock is held +#define SIGNAL_FLAG_DONT_RESTART_SYSCALL (0x20000) #ifdef __cplusplus Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-02-21 10:10:17 UTC (rev 24044) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-02-21 13:19:54 UTC (rev 24045) @@ -499,6 +499,9 @@ if (thread->state == B_THREAD_SUSPENDED) scheduler_enqueue_in_run_queue(thread); + if ((flags & SIGNAL_FLAG_DONT_RESTART_SYSCALL) != 0) + atomic_or(&thread->flags, THREAD_FLAGS_DONT_RESTART_SYSCALL); + atomic_and(&thread->sig_pending, ~STOP_SIGNALS); // remove any pending stop signals break; Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-02-21 10:10:17 UTC (rev 24044) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-02-21 13:19:54 UTC (rev 24045) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -2345,7 +2345,10 @@ if (id <= 0) return B_BAD_VALUE; - return send_signal(id, SIGCONT); + return send_signal_etc(id, SIGCONT, SIGNAL_FLAG_DONT_RESTART_SYSCALL); + // This retains compatibility to BeOS which documents the + // combination of suspend_thread() and resume_thread() to + // interrupt threads waiting on semaphores. } From axeld at mail.berlios.de Thu Feb 21 16:00:25 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 21 Feb 2008 16:00:25 +0100 Subject: [Haiku-commits] r24046 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200802211500.m1LF0PkQ009724@sheep.berlios.de> Author: axeld Date: 2008-02-21 16:00:19 +0100 (Thu, 21 Feb 2008) New Revision: 24046 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24046&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp Log: * When deleting a socket, we also need to delete all of its children. * This fixes a KDL I often seen when launching firefox. Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-02-21 13:19:54 UTC (rev 24045) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-02-21 15:00:19 UTC (rev 24046) @@ -65,6 +65,21 @@ } +static void +delete_children(struct list *list) +{ + while (true) { + net_socket_private *child + = (net_socket_private *)list_remove_head_item(list); + if (child == NULL) + break; + + child->parent = NULL; + socket_delete(child); + } +} + + static status_t create_socket(int family, int type, int protocol, net_socket_private **_socket) { @@ -364,6 +379,10 @@ list_remove_item(&sSocketList, socket); benaphore_unlock(&sSocketLock); + // also delete all children of this socket + delete_children(&socket->pending_children); + delete_children(&socket->connected_children); + put_domain_protocols(socket); benaphore_destroy(&socket->lock); delete_select_sync_pool(socket->select_pool); From axeld at mail.berlios.de Thu Feb 21 17:15:00 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 21 Feb 2008 17:15:00 +0100 Subject: [Haiku-commits] r24047 - haiku/trunk/src/system/kernel Message-ID: <200802211615.m1LGF0iQ018394@sheep.berlios.de> Author: axeld Date: 2008-02-21 17:15:00 +0100 (Thu, 21 Feb 2008) New Revision: 24047 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24047&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: team::parent is NULL in case of the kernel - Expander crashed reliably when expanding something with it. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-02-21 15:00:19 UTC (rev 24046) +++ haiku/trunk/src/system/kernel/team.cpp 2008-02-21 16:15:00 UTC (rev 24047) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -1774,7 +1774,8 @@ struct team* team = group->teams; while (team != NULL) { struct team* parent = team->parent; - if (team->id != dyingProcess && parent->id != dyingProcess + if (team->id != dyingProcess && parent != NULL + && parent->id != dyingProcess && parent->group_id != group->id && parent->session_id == group->session->id) { return false; From axeld at pinc-software.de Thu Feb 21 18:19:57 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 21 Feb 2008 18:19:57 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23957_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/drivers/bluetooth/h2/h2generic?= In-Reply-To: <200802132007.m1DK7qXs032170@sheep.berlios.de> Message-ID: <31284524376-BeMail@zon> oruizdorantes at BerliOS wrote: > Log: > Make the driver almost build for target R5. How is the best way in > the Jamfile to compile it together > with src/system/kernel/util/list.c only for target R5? The Jamfile for libtracker.so (in src/kits/tracker/Jamfile) does something like this for the vector icon library. Just put the list.c source in a variable conditionally and and add that variable to your list of sources. Bye, Axel. From axeld at pinc-software.de Thu Feb 21 18:24:05 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 21 Feb 2008 18:24:05 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r22180_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/file=5Fsystems/bfs?= In-Reply-To: <200709050307.l8537eo6009398@sheep.berlios.de> Message-ID: <31532353619-BeMail@zon> bonefish at BerliOS wrote: > Log: > Disabled the attribute name checks for "name", "size", and > "last_modified" for the time being. BeOS allows creating and reading > attributes with those names. Can we enable that check again now? Even though BeOS allows creating attributes with these names, their index doesn't fit to them, and I'm not sure BFS (either of them) won't do something stupid if you actually have a string attribute called "name". Bye, Axel. From oliver.ruiz.dorantes at gmail.com Thu Feb 21 18:35:21 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Thu, 21 Feb 2008 18:35:21 +0100 Subject: [Haiku-commits] r23957 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic In-Reply-To: <31284524376-BeMail@zon> References: <200802132007.m1DK7qXs032170@sheep.berlios.de> <31284524376-BeMail@zon> Message-ID: Thanks Axel;) will try tonight 2008/2/21, Axel D?rfler : > > oruizdorantes at BerliOS wrote: > > Log: > > Make the driver almost build for target R5. How is the best way in > > the Jamfile to compile it together > with src/system/kernel/util/list.c > only for target R5? > > > The Jamfile for libtracker.so (in src/kits/tracker/Jamfile) does > something like this for the vector icon library. Just put the list.c > source in a variable conditionally and and add that variable to your > list of sources. > > Bye, > > Axel. > > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingo_weinhold at gmx.de Thu Feb 21 18:53:24 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 21 Feb 2008 18:53:24 +0100 Subject: [Haiku-commits] r22180 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <31532353619-BeMail@zon> References: <31532353619-BeMail@zon> Message-ID: <20080221185324.390.1@knochen-vm.1203615599.fake> On 2008-02-21 at 18:24:05 [+0100], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > Log: > > Disabled the attribute name checks for "name", "size", and > > "last_modified" for the time being. BeOS allows creating and reading > > attributes with those names. > > Can we enable that check again now? Well, try and see what happens. If it breaks the WonderBrush optional package installation, kick Stippi. :-P CU, Ingo From oliver.ruiz.dorantes at gmail.com Thu Feb 21 20:20:02 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Thu, 21 Feb 2008 20:20:02 +0100 Subject: [Haiku-commits] r23957 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic In-Reply-To: <31284524376-BeMail@zon> References: <200802132007.m1DK7qXs032170@sheep.berlios.de> <31284524376-BeMail@zon> Message-ID: Hi Axel, Almost works, but the problem is: At defining the relative path: ../../../../../../system/kernel/util/list.c , it tries to create the resulting object file in the current path +concat+ that relative one. Ending up not being able to create that file. Do I explain myself ? any hint? Thanks! 2008/2/21, Axel D?rfler : > > oruizdorantes at BerliOS wrote: > > Log: > > Make the driver almost build for target R5. How is the best way in > > the Jamfile to compile it together > with src/system/kernel/util/list.c > only for target R5? > > > The Jamfile for libtracker.so (in src/kits/tracker/Jamfile) does > something like this for the vector icon library. Just put the list.c > source in a variable conditionally and and add that variable to your > list of sources. > > Bye, > > Axel. > > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From korli at mail.berlios.de Thu Feb 21 20:57:04 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 21 Feb 2008 20:57:04 +0100 Subject: [Haiku-commits] r24048 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200802211957.m1LJv49A030741@sheep.berlios.de> Author: korli Date: 2008-02-21 20:57:04 +0100 (Thu, 21 Feb 2008) New Revision: 24048 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24048&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile Log: added kernel/util/list.c for non haiku targets Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile 2008-02-21 16:15:00 UTC (rev 24047) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/Jamfile 2008-02-21 19:57:04 UTC (rev 24048) @@ -4,13 +4,23 @@ UsePrivateHeaders net kernel bluetooth ; +local r5_src = ; +if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { + UseHeaders [ FDirName $(HAIKU_TOP) headers os bluetooth ] : true ; + r5_src = list.c ; +} + KernelAddon h2generic : h2generic.c h2transactions.c h2upper.c h2util.c snet_buffer.c + $(r5_src) ; + +SEARCH on [ FGristFiles $(r5_src) + ] = [ FDirName $(HAIKU_TOP) src system kernel util ] ; Package haiku-h2generic-cvs : h2generic : From korli at users.berlios.de Thu Feb 21 20:58:25 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 21 Feb 2008 20:58:25 +0100 Subject: [Haiku-commits] r23957 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic In-Reply-To: References: <200802132007.m1DK7qXs032170@sheep.berlios.de> <31284524376-BeMail@zon> Message-ID: Hi Oliver, 2008/2/21, Oliver Ruiz Dorantes : > Do I explain myself ? > any hint? > I changed the Jamfile according to your needs in r24048. Not sure it would help to build :) Bye, J?r?me From stippi at mail.berlios.de Thu Feb 21 21:10:42 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 21 Feb 2008 21:10:42 +0100 Subject: [Haiku-commits] r24049 - haiku/trunk/src/apps/resedit Message-ID: <200802212010.m1LKAgiu031580@sheep.berlios.de> Author: stippi Date: 2008-02-21 21:10:41 +0100 (Thu, 21 Feb 2008) New Revision: 24049 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24049&view=rev Modified: haiku/trunk/src/apps/resedit/App.cpp haiku/trunk/src/apps/resedit/Jamfile haiku/trunk/src/apps/resedit/ResWindow.cpp haiku/trunk/src/apps/resedit/ResWindow.h Log: Applied patch by Maurice Kalinowski with additional changes by myself: * Fixed ResEdit build. * Small cleanups and simplifications. * Removed reference to CapitalB resource in ReadyToRun(). Modified: haiku/trunk/src/apps/resedit/App.cpp =================================================================== --- haiku/trunk/src/apps/resedit/App.cpp 2008-02-21 19:57:04 UTC (rev 24048) +++ haiku/trunk/src/apps/resedit/App.cpp 2008-02-21 20:10:41 UTC (rev 24049) @@ -17,6 +17,7 @@ return 0; } + App::App(void) : BApplication("application/x-vnd.Haiku-ResEdit"), fWindowCount(0) @@ -36,19 +37,8 @@ void App::ReadyToRun(void) { -/* - if (fWindowCount < 1) { - ResWindow *win = new ResWindow(BRect(50,100,600,400)); - win->Show(); - } -*/ - if (fWindowCount < 1) { - BEntry entry("/boot/develop/projects/ResEdit/CapitalBe.rsrc"); - entry_ref ref; - entry.GetRef(&ref); - ResWindow *win = new ResWindow(BRect(50,100,600,400),&ref); - win->Show(); - } + if (fWindowCount < 1) + new ResWindow(BRect(50, 100, 600, 400)); } @@ -82,27 +72,23 @@ void App::ArgvReceived(int32 argc, char** argv) { - int i; - for (i = 1; i < argc; i++) { + for (int32 i = 1; i < argc; i++) { BEntry entry(argv[i]); entry_ref ref; if (entry.GetRef(&ref) < B_OK) continue; - ResWindow *win = new ResWindow(BRect(50,100,600,400),&ref); - win->Show(); + new ResWindow(BRect(50, 100, 600, 400), &ref); } } + void App::RefsReceived(BMessage *msg) { entry_ref ref; - int32 i=0; - while (msg->FindRef("refs",i,&ref) == B_OK) { - ResWindow *win = new ResWindow(BRect(50,100,600,400),&ref); - win->Show(); - i++; - } + int32 i = 0; + while (msg->FindRef("refs", i++, &ref) == B_OK) + new ResWindow(BRect(50, 100, 600, 400), &ref); } Modified: haiku/trunk/src/apps/resedit/Jamfile =================================================================== --- haiku/trunk/src/apps/resedit/Jamfile 2008-02-21 19:57:04 UTC (rev 24048) +++ haiku/trunk/src/apps/resedit/Jamfile 2008-02-21 20:10:41 UTC (rev 24049) @@ -26,5 +26,5 @@ ResourceRoster.cpp ResView.cpp ResWindow.cpp - : be tracker translation + : be tracker translation libcolumnlistview.a ; Modified: haiku/trunk/src/apps/resedit/ResWindow.cpp =================================================================== --- haiku/trunk/src/apps/resedit/ResWindow.cpp 2008-02-21 19:57:04 UTC (rev 24048) +++ haiku/trunk/src/apps/resedit/ResWindow.cpp 2008-02-21 20:10:41 UTC (rev 24049) @@ -14,10 +14,13 @@ { be_app->PostMessage(M_REGISTER_WINDOW); - ResView *child = new ResView(Bounds(), "resview", B_FOLLOW_ALL, B_WILL_DRAW, ref); + ResView *child = new ResView(Bounds(), "resview", B_FOLLOW_ALL, + B_WILL_DRAW, ref); AddChild(child); SetTitle(child->Filename()); + + Show(); } Modified: haiku/trunk/src/apps/resedit/ResWindow.h =================================================================== --- haiku/trunk/src/apps/resedit/ResWindow.h 2008-02-21 19:57:04 UTC (rev 24048) +++ haiku/trunk/src/apps/resedit/ResWindow.h 2008-02-21 20:10:41 UTC (rev 24049) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2006, Haiku, Inc. + * Copyright (c) 2005-2008, Haiku, Inc. * Distributed under the terms of the MIT license. * * Author: @@ -10,13 +10,16 @@ #include -class ResWindow : public BWindow -{ + +struct entry_ref; + +class ResWindow : public BWindow { public: - ResWindow(const BRect &rect, - const entry_ref *ref=NULL); - ~ResWindow(void); - bool QuitRequested(void); + ResWindow(const BRect& rect, + const entry_ref* ref = NULL); + virtual ~ResWindow(); + + virtual bool QuitRequested(); }; -#endif +#endif // RESWIN_H From oliver.ruiz.dorantes at gmail.com Thu Feb 21 21:44:54 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Thu, 21 Feb 2008 21:44:54 +0100 Subject: [Haiku-commits] r23957 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic In-Reply-To: References: <200802132007.m1DK7qXs032170@sheep.berlios.de> <31284524376-BeMail@zon> Message-ID: Hi J?r?me It certainly does, thanks!! although to be honest I dont understand completelly the lines you added, no worries someday i will ;) Regards, Oliver 2008/2/21, J?r?me Duval : > > Hi Oliver, > > 2008/2/21, Oliver Ruiz Dorantes : > > > Do I explain myself ? > > any hint? > > > > > I changed the Jamfile according to your needs in r24048. Not sure it > would help to build :) > > Bye, > > J?r?me > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From oruizdorantes at mail.berlios.de Thu Feb 21 23:17:54 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Thu, 21 Feb 2008 23:17:54 +0100 Subject: [Haiku-commits] r24050 - haiku/trunk/headers/os/bluetooth Message-ID: <200802212217.m1LMHs9K012334@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-21 23:17:54 +0100 (Thu, 21 Feb 2008) New Revision: 24050 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24050&view=rev Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h Log: Add using namespace pragmas Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-02-21 20:10:41 UTC (rev 24049) +++ haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-02-21 22:17:54 UTC (rev 24050) @@ -63,4 +63,8 @@ } +#ifndef _BT_USE_EXPLICIT_NAMESPACE +using Bluetooth::LocalDevice; #endif + +#endif From oruizdorantes at mail.berlios.de Thu Feb 21 23:29:40 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Thu, 21 Feb 2008 23:29:40 +0100 Subject: [Haiku-commits] r24051 - haiku/trunk/src/bin Message-ID: <200802212229.m1LMTePa013771@sheep.berlios.de> Author: oruizdorantes Date: 2008-02-21 23:29:40 +0100 (Thu, 21 Feb 2008) New Revision: 24051 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24051&view=rev Added: haiku/trunk/src/bin/bt_dev_info.cpp Log: Small tool to check all the installed Bluetooth Local devices, will be usefull until we have a decent preference or a blue icon in the deskbar for testing. Added: haiku/trunk/src/bin/bt_dev_info.cpp =================================================================== --- haiku/trunk/src/bin/bt_dev_info.cpp 2008-02-21 22:17:54 UTC (rev 24050) +++ haiku/trunk/src/bin/bt_dev_info.cpp 2008-02-21 22:29:40 UTC (rev 24051) @@ -0,0 +1,68 @@ +/* + * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * + * All rights reserved. Distributed under the terms of the MIT License. + * + */ + + +#include +#include + +#include + + +void +DumpInfo(LocalDevice* device) +{ + + + +} + +static status_t +LocalDeviceError(status_t status) +{ + // switch (status) {} + fprintf(stderr,"No Device/s found"); + + return status; +} + + +int +main(int argc, char *argv[]) +{ + LocalDevice* ld = NULL; + + if(argc == 2) { + // device specified + ld = LocalDevice::GetLocalDevice(atoi(argv[0])); + if (ld == NULL) + return LocalDeviceError(ENODEV); + + DumpInfo(ld); + + } else if (argc == 1) { + // show all devices + LocalDevice* firstLocalDevice = LocalDevice::GetLocalDevice(); + + if (firstLocalDevice == NULL) + return LocalDeviceError(ENODEV); + + printf("Listing %ld Bluetooth devices ...\n", LocalDevice::GetLocalDeviceCount()); + + ld = firstLocalDevice; + do { + DumpInfo(ld); + ld = LocalDevice::GetLocalDevice(); + + } while (ld != firstLocalDevice); + + return B_OK; + + } else { + fprintf(stderr,"Usage: bt_dev_info [device]\n"); + return B_ERROR; + } +} From mmu_man at mail.berlios.de Thu Feb 21 23:41:50 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 21 Feb 2008 23:41:50 +0100 Subject: [Haiku-commits] r24052 - in haiku/trunk: headers/private/kernel src/add-ons/kernel/debugger/auto_stack_trace src/add-ons/kernel/debugger/hangman src/add-ons/kernel/debugger/invalidate_on_exit Message-ID: <200802212241.m1LMfolf015382@sheep.berlios.de> Author: mmu_man Date: 2008-02-21 23:41:49 +0100 (Thu, 21 Feb 2008) New Revision: 24052 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24052&view=rev Modified: haiku/trunk/headers/private/kernel/debug.h haiku/trunk/src/add-ons/kernel/debugger/auto_stack_trace/auto_stack_trace.cpp haiku/trunk/src/add-ons/kernel/debugger/hangman/hangman.c haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp Log: Add debugger module hooks to implement alternative io (I need laplink debugging...) Modified: haiku/trunk/headers/private/kernel/debug.h =================================================================== --- haiku/trunk/headers/private/kernel/debug.h 2008-02-21 22:29:40 UTC (rev 24051) +++ haiku/trunk/headers/private/kernel/debug.h 2008-02-21 22:41:49 UTC (rev 24052) @@ -49,6 +49,11 @@ void (*enter_debugger)(void); void (*exit_debugger)(void); + + // io hooks + int (*debugger_puts)(const char *str, int32 length); + int (*debugger_getchar)(void); + // TODO: add hooks for tunnelling gdb ? }; extern int dbg_register_file[B_MAX_CPU_COUNT][14]; Modified: haiku/trunk/src/add-ons/kernel/debugger/auto_stack_trace/auto_stack_trace.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/auto_stack_trace/auto_stack_trace.cpp 2008-02-21 22:29:40 UTC (rev 24051) +++ haiku/trunk/src/add-ons/kernel/debugger/auto_stack_trace/auto_stack_trace.cpp 2008-02-21 22:41:49 UTC (rev 24052) @@ -31,6 +31,8 @@ &std_ops }, enter_debugger, + NULL, + NULL, NULL }; Modified: haiku/trunk/src/add-ons/kernel/debugger/hangman/hangman.c =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/hangman/hangman.c 2008-02-21 22:29:40 UTC (rev 24051) +++ haiku/trunk/src/add-ons/kernel/debugger/hangman/hangman.c 2008-02-21 22:41:49 UTC (rev 24052) @@ -473,6 +473,8 @@ &std_ops }, NULL, + NULL, + NULL, NULL }; Modified: haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp 2008-02-21 22:29:40 UTC (rev 24051) +++ haiku/trunk/src/add-ons/kernel/debugger/invalidate_on_exit/invalidate_on_exit.cpp 2008-02-21 22:41:49 UTC (rev 24052) @@ -71,7 +71,9 @@ }, NULL, - exit_debugger + exit_debugger, + NULL, + NULL }; module_info *modules[] = { From korli at mail.berlios.de Thu Feb 21 23:51:21 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 21 Feb 2008 23:51:21 +0100 Subject: [Haiku-commits] r24053 - haiku/trunk/src/bin/coreutils/lib Message-ID: <200802212251.m1LMpLVm016158@sheep.berlios.de> Author: korli Date: 2008-02-21 23:51:19 +0100 (Thu, 21 Feb 2008) New Revision: 24053 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24053&view=rev Modified: haiku/trunk/src/bin/coreutils/lib/Jamfile haiku/trunk/src/bin/coreutils/lib/config.h Log: tentative at fixing bug #1776 lchown replacement was using rpl_chown too (could not understand how this works) Modified: haiku/trunk/src/bin/coreutils/lib/Jamfile =================================================================== --- haiku/trunk/src/bin/coreutils/lib/Jamfile 2008-02-21 22:41:49 UTC (rev 24052) +++ haiku/trunk/src/bin/coreutils/lib/Jamfile 2008-02-21 22:51:19 UTC (rev 24053) @@ -87,7 +87,7 @@ imaxtostr.c inet_ntop.c isapipe.c - lchown.c +# lchown.c linebuffer.c localcharset.c long-options.c Modified: haiku/trunk/src/bin/coreutils/lib/config.h =================================================================== --- haiku/trunk/src/bin/coreutils/lib/config.h 2008-02-21 22:41:49 UTC (rev 24052) +++ haiku/trunk/src/bin/coreutils/lib/config.h 2008-02-21 22:51:19 UTC (rev 24053) @@ -722,7 +722,7 @@ /* #undef HAVE_LCHMOD */ /* Define to 1 if you have the `lchown' function. */ -/* #undef HAVE_LCHOWN */ +#define HAVE_LCHOWN 1 /* Define to 1 if you have the `dgc' library (-ldgc). */ /* #undef HAVE_LIBDGC */ From mmu_man at mail.berlios.de Fri Feb 22 00:35:55 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 22 Feb 2008 00:35:55 +0100 Subject: [Haiku-commits] r24054 - haiku/trunk/src/system/kernel/debug Message-ID: <200802212335.m1LNZto6030402@sheep.berlios.de> Author: mmu_man Date: 2008-02-22 00:35:44 +0100 (Fri, 22 Feb 2008) New Revision: 24054 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24054&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.cpp Log: Call debugger_puts hooks on modules when serial debug output is enabled (modules themselves must reject loading if they don't find mymodule_debug_output in kernel settings). Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-21 22:51:19 UTC (rev 24053) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-02-21 23:35:44 UTC (rev 24054) @@ -91,20 +91,30 @@ static void kputchar(char c) { + uint32 i; + if (sSerialDebugEnabled) arch_debug_serial_putchar(c); if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_putchar(c); + for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) + if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts) + sDebuggerModules[i]->debugger_puts(&c, sizeof(c)); } void kputs(const char *s) { + uint32 i; + if (sSerialDebugEnabled) arch_debug_serial_puts(s); if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_puts(s); + for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) + if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts) + sDebuggerModules[i]->debugger_puts(s, strlen(s)); } @@ -1159,6 +1169,7 @@ { if (sMessageRepeatCount > 0) { int32 length; + uint32 i; if (sMessageRepeatCount > 1) { static char temp[40]; @@ -1171,6 +1182,9 @@ syslog_write(temp, length); if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_puts(temp); + for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) + if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts) + sDebuggerModules[i]->debugger_puts(temp, length); } else { // if we only have one repeat just reprint the last buffer if (sSerialDebugEnabled) @@ -1179,6 +1193,9 @@ syslog_write(sLastOutputBuffer, strlen(sLastOutputBuffer)); if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_puts(sLastOutputBuffer); + for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) + if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts) + sDebuggerModules[i]->debugger_puts(sLastOutputBuffer, strlen(sLastOutputBuffer)); } sMessageRepeatFirstTime = 0; @@ -1211,6 +1228,7 @@ { cpu_status state; int32 length; + uint32 i; // ToDo: maybe add a non-interrupt buffer and path that only // needs to acquire a semaphore instead of needing to disable @@ -1239,6 +1257,9 @@ syslog_write(sOutputBuffer, length); if (sBlueScreenEnabled || sDebugScreenEnabled) blue_screen_puts(sOutputBuffer); + for (i = 0; sSerialDebugEnabled && i < kMaxDebuggerModules; i++) + if (sDebuggerModules[i] && sDebuggerModules[i]->debugger_puts) + sDebuggerModules[i]->debugger_puts(sOutputBuffer, length); memcpy(sLastOutputBuffer, sOutputBuffer, length); sLastOutputBuffer[length] = 0; From mmu_man at mail.berlios.de Fri Feb 22 00:37:06 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 22 Feb 2008 00:37:06 +0100 Subject: [Haiku-commits] r24055 - in haiku/trunk/src/add-ons/kernel/debugger: . bochs laplinkll Message-ID: <200802212337.m1LNb6HO000481@sheep.berlios.de> Author: mmu_man Date: 2008-02-22 00:36:59 +0100 (Fri, 22 Feb 2008) New Revision: 24055 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24055&view=rev Added: haiku/trunk/src/add-ons/kernel/debugger/bochs/ haiku/trunk/src/add-ons/kernel/debugger/bochs/Jamfile haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp haiku/trunk/src/add-ons/kernel/debugger/laplinkll/ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.h Modified: haiku/trunk/src/add-ons/kernel/debugger/Jamfile Log: * Bochs debug output * laplink low level debug output I wrote for zeta, needs some work. Modified: haiku/trunk/src/add-ons/kernel/debugger/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/Jamfile 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/Jamfile 2008-02-21 23:36:59 UTC (rev 24055) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel debugger ; SubInclude HAIKU_TOP src add-ons kernel debugger auto_stack_trace ; +SubInclude HAIKU_TOP src add-ons kernel debugger bochs ; SubInclude HAIKU_TOP src add-ons kernel debugger hangman ; SubInclude HAIKU_TOP src add-ons kernel debugger invalidate_on_exit ; +SubInclude HAIKU_TOP src add-ons kernel debugger laplinkll ; Added: haiku/trunk/src/add-ons/kernel/debugger/bochs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/bochs/Jamfile 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/bochs/Jamfile 2008-02-21 23:36:59 UTC (rev 24055) @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src add-ons kernel debugger bochs ; + +UsePrivateHeaders kernel ; + +KernelAddon bochs : + bochs.cpp + ; Added: haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp 2008-02-21 23:36:59 UTC (rev 24055) @@ -0,0 +1,70 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol, revol at free.fr + */ + + +#include +#include +#include + +static isa_module_info *sISAModule; + + +static int +debugger_puts(const char *s, int32 length) +{ + int i; + for (i = 0; i < length; i++) + sISAModule->write_io_8(0xe9, s[i]); + return i; +} + + +static status_t +std_ops(int32 op, ...) +{ + void *handle; + bool load = true;//false; + + switch (op) { + case B_MODULE_INIT: + handle = load_driver_settings("kernel"); + if (handle) { + load = get_driver_boolean_parameter(handle, + "bochs_debug_output", load, true); + unload_driver_settings(handle); + } + if (load) { + if (get_module(B_ISA_MODULE_NAME, (module_info **)&sISAModule) < B_OK) + return B_ERROR; + } + return load ? B_OK : B_ERROR; + case B_MODULE_UNINIT: + put_module(B_ISA_MODULE_NAME); + return B_OK; + } + return B_BAD_VALUE; +} + + +static struct debugger_module_info sModuleInfo = { + { + "debugger/bochs/v1", + 0, + &std_ops + }, + NULL, + NULL, + debugger_puts, + NULL +}; + +module_info *modules[] = { + (module_info *)&sModuleInfo, + NULL +}; + Added: haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile 2008-02-21 23:36:59 UTC (rev 24055) @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src add-ons kernel debugger laplinkll ; + +UsePrivateHeaders kernel ; + +KernelAddon laplinkll : + laplinkll.c + ; Added: haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp 2008-02-21 23:36:59 UTC (rev 24055) @@ -0,0 +1,452 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol, revol at free.fr + * + * Copyright 2005, Fran?ois Revol. + */ + +/* + Description: Implements a tty on top of the parallel port, + using PLIP-like byte-by-byte protocol. + Low level stuff. +*/ + + +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//XXX: move to Jamfile when adding driver +#define _BUILDING_kernel 1 + +#if _BUILDING_kernel +#include +#endif + +#include "laplinkll.h" + +enum { + st_sync = 0, // syncing... + st_lsb, + st_msb, + st_error +}; + +#pragma mark // raw access + +static inline uint8 read_status(uint32 port) +{ + uint8 val; + val = read_io_8(port+1); + return val; +} + +static inline void write_control(uint32 port, uint8 val) +{ + write_io_8(port+2, val); +} + +static inline void write_data(uint32 port, uint8 val) +{ + write_io_8(port, val); +} + +#pragma mark // framing + +status_t ll_send_sof(laplink_state *st) +{ + uint8 v; + int tries = LPTSOFTRIES; + if (st->rstate != st_sync || st->wstate != st_sync) + return B_TIMED_OUT; + // check for idle bus + if ((read_status(st->port) & 0xf8) != 0x80) + return B_TIMED_OUT; + // raise ACK + write_data(st->port, 0x08); + do { + spin(LPTSPIN); + v = read_status(st->port); + if (st->rstate != st_sync) + return B_TIMED_OUT; + if (tries-- == 0) + return B_TIMED_OUT; + } while (!(v & 0x08)); + st->wstate = st_lsb; + return B_OK; +} + +status_t ll_check_sof(laplink_state *st) +{ + uint8 v; + if (st->rstate != st_sync || st->wstate != st_sync) + return EINTR; + v = read_status(st->port); + if ((v & 0xf8) != 0xc0) + return EINTR; + return B_OK; +} + +status_t ll_ack_sof(laplink_state *st) +{ + write_data(st->port, 0x01); // ack the sof + st->rstate = st_lsb; + return B_OK; +} + +status_t ll_send_eof(laplink_state *st) +{ + /* + if (st->rstate != st_sync || st->wstate != st_sync) + return B_TIMED_OUT; + */ + st->rstate = st_sync; + st->wstate = st_sync; + write_data(st->port, 0x00); + return B_OK; +} + +#pragma mark // nibbles + +status_t ll_send_lnibble(laplink_state *st, uint8 v) +{ + int tries = LPTNIBTRIES; + uint8 s; + if (st->rstate != st_sync) + goto err; + if (st->wstate != st_lsb) + goto err; + write_data(st->port, v & 0x0f); + spin(10); + write_data(st->port, (v & 0x0f) | 0x10); + // wait for ack + do { + s = read_status(st->port); + if (tries-- == 0) + goto err; + spin(LPTSPIN); + } while (s & 0x80); + st->wstate = st_msb; + return B_OK; +err: + st->wstate = st_sync; + return B_TIMED_OUT; +} + +status_t ll_send_mnibble(laplink_state *st, uint8 v) +{ + int tries = LPTNIBTRIES; + uint8 s; + if (st->rstate != st_sync) + goto err; + if (st->wstate != st_msb) + goto err; + write_data(st->port, (v >> 4) | 0x10); + spin(10); + write_data(st->port, (v >> 4)); + // wait for ack + do { + s = read_status(st->port); + if (tries-- == 0) + goto err; + spin(LPTSPIN); + } while (!(s & 0x80)); + st->wstate = st_lsb;//st_sync; + return B_OK; +err: + st->wstate = st_sync; + return B_TIMED_OUT; +} + +status_t ll_wait_lnibble(laplink_state *st, uint8 *v) +{ + int tries = LPTNIBTRIES; + uint8 s; + // wait for data + do { + s = read_status(st->port); + if (tries-- == 0) + goto err; + spin(LPTSPIN); + } while ((s & 0x80) || (s != read_status(st->port))); + // get the nibble + *v = (s >> 3) & 0x0f; + st->rstate = st_msb; + // tell we got that one + write_data(st->port, 0x10); + return B_OK; +err: + st->rstate = st_sync; + return B_TIMED_OUT; +} + +status_t ll_wait_mnibble(laplink_state *st, uint8 *v) +{ + int tries = LPTNIBTRIES; + uint8 s; + // wait for data + do { + s = read_status(st->port); + if (tries-- == 0) + goto err; + spin(LPTSPIN); + } while (!(s & 0x80) || (s != read_status(st->port))); + // get the nibble + *v |= (s << (4-3)) & 0xf0; + st->rstate = st_sync; + // tell we got that one + write_data(st->port, 0x00); + return B_OK; +err: + st->rstate = st_sync; + return B_TIMED_OUT; +} + +#pragma mark // byte mode + +status_t ll_send_byte(laplink_state *st, uint8 v) +{ + status_t err; + err = ll_send_sof(st); + if (!err) + err = ll_send_lnibble(st, v); + if (!err) + err = ll_send_mnibble(st, v); + if (!err) + err = ll_send_eof(st); + return err; +} + +status_t ll_check_byte(laplink_state *st, uint8 *v) +{ + status_t err; + *v = 0; + err = ll_check_sof(st); + if (err) + return err; + err = ll_ack_sof(st); + if (!err) + err = ll_wait_lnibble(st, v); + if (!err) + err = ll_wait_mnibble(st, v); + if (!err) + err = ll_send_eof(st); + return err; +} + +status_t ll_wait_byte(laplink_state *st, uint8 *v) +{ + status_t err; + do { + spin(LPTSPIN); + err = ll_check_byte(st, v); + } while (err < B_OK);// } while (err == B_TIMED_OUT); + return err; +} + +#pragma mark // frame mode + +// unframed +static inline status_t ll_send_byte_uf(laplink_state *st, uint8 v) +{ + status_t err; + err = ll_send_lnibble(st, v); + if (!err) + err = ll_send_mnibble(st, v); + return err; +} + +status_t ll_get_byte_uf(laplink_state *st, uint8 *v) +{ + status_t err; + *v = 0; + err = ll_wait_lnibble(st, v); + if (!err) + err = ll_wait_mnibble(st, v); + return err; +} + +status_t ll_send_frame(laplink_state *st, const uint8 *buff, size_t *len) +{ + status_t err; + uint16 pktlen = *len; + uint8 cksum = 0; + *len = 0; + err = ll_send_sof(st); + if (err) + return err; + err = ll_send_byte_uf(st, pktlen & 0xff); + if (err) + goto err; + err = ll_send_byte_uf(st, pktlen >> 8); + if (err) + goto err; + for (*len = 0; *len < pktlen; (*len)++) { + err = ll_send_byte_uf(st, buff[*len]); + if (err) + goto err; + cksum += buff[*len]; + } + err = ll_send_byte_uf(st, cksum); + if (err) + goto err; + + /*err =*/ ll_send_eof(st); +err: + + if (err) { // back to idle + *len = 0; + ll_send_eof(st); + } + return err; +} + +status_t ll_check_frame(laplink_state *st, uint8 *buff, size_t *len) +{ + status_t err; + uint16 pktlen = 0; + uint16 wanted; + uint8 cksum = 0; + uint8 byte; + int i; + err = ll_check_sof(st); + if (err) + goto err; + err = ll_ack_sof(st); + if (err) + goto err; + // pktlen + err = ll_get_byte_uf(st, &byte); + if (err) + goto err; + pktlen = byte; + err = ll_get_byte_uf(st, &byte); + if (err) + goto err; + pktlen |= byte << 8; + cksum = 0; + /*if (pktlen > *len) { + dprintf("laplink: check_frame: packet truncated from %d to %d\n", pktlen, *len); + }*/ + wanted = MIN(pktlen, *len); + for (*len = 0; (*len < pktlen); (*len)++) { + err = ll_get_byte_uf(st, &byte); + if (err) + goto err; + if (*len < wanted) + buff[*len] = byte; + cksum += byte; + } + err = ll_get_byte_uf(st, &byte); + if (err) + goto err; + /* + if (cksum != byte) { + dprintf("laplink: check_frame: wrong cksum\n"); + }*/ +err: + ll_send_eof(st); + return err; +} + +status_t ll_wait_frame(laplink_state *st, uint8 *buff, size_t *len) +{ + status_t err; + do { + spin(LPTSPIN); + err = ll_check_frame(st, buff, len); + } while (err < B_OK);// } while (err == B_TIMED_OUT); + return err; +} + +#pragma mark // kdebug io handler + +#if _BUILDING_kernel +#define BUFFSZ 256 + +static laplink_state llst; +static char laplink_in_buf[BUFFSZ]; +static char *laplink_in_ptr; +static size_t laplink_in_avail; +static char laplink_out_buf[BUFFSZ]; + + +static status_t debug_init_laplink(void *kernel_settings) +{ + (void)kernel_settings; + llst.port = LPTBASE; + llst.rstate = st_sync; + llst.wstate = st_sync; + laplink_in_ptr = laplink_in_buf; + laplink_in_avail = 0; + return B_OK; +} + +static int debug_write_laplink(int f, const char *buf, int count) +{ + status_t err; + size_t len; + int tries; + int i, prev = 0; + + // fix up CR LF issues... to a local buffer (which will get truncated) + if (count > 1) { + for (i = 0; (i < BUFFSZ-1) && count; i++, buf++, count--) { + if ((*buf == '\n') && (prev != '\r')) + laplink_out_buf[i++] = '\r'; + laplink_out_buf[i] = *buf; + prev = *buf; + } + count = i; + buf = laplink_out_buf; + } + + tries = 5; + do { + len = count; + err = ll_send_frame(&llst, buf, &len); + } while (err && tries--); + if (err) + return 0; + return len; +} + +static int debug_read_laplink(void) +{ + status_t err = B_OK; + while (laplink_in_avail < 1) { + laplink_in_avail = BUFFSZ; + laplink_in_ptr = laplink_in_buf; + err = ll_wait_frame(&llst, laplink_in_buf, &laplink_in_avail); + if (err) + laplink_in_avail = 0; + } + laplink_in_avail--; + return *laplink_in_ptr++; +} + + +kdebug_io_handler laplink_debug_io = { + "laplink", + debug_init_laplink, + debug_write_laplink, + debug_read_laplink, + NULL, + NULL, + NULL +}; + + +#endif + Added: haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.h =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.h 2008-02-21 23:35:44 UTC (rev 24054) +++ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.h 2008-02-21 23:36:59 UTC (rev 24055) @@ -0,0 +1,57 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fran?ois Revol, revol at free.fr + * + * Copyright 2005, Fran?ois Revol. + */ + +/* + Description: Implements a tty on top of the parallel port, + using PLIP-like byte-by-byte protocol. + Low level stuff. +*/ + + +// LPT1 +#define LPTBASE 0x378 +#define LPTIRQ 7 +#define LPTDONGLE "/dev/misc/dongle/parallel1" +#define LPTSPIN 30 +#define LPTSOFTRIES 1000 +#define LPTNIBTRIES 100 +#define LAPLINK_MAX_FRAME 512 + +typedef struct laplink_state { + int32 port; + int32 irq; + + uint8 rstate; + uint8 wstate; +} laplink_state; + +// framing +extern status_t ll_send_sof(laplink_state *st); +extern status_t ll_check_sof(laplink_state *st); +extern status_t ll_ack_sof(laplink_state *st); +extern status_t ll_send_eof(laplink_state *st); + +// nibbles +extern status_t ll_send_lnibble(laplink_state *st, uint8 v); +extern status_t ll_send_mnibble(laplink_state *st, uint8 v); +extern status_t ll_wait_lnibble(laplink_state *st, uint8 *v); +extern status_t ll_wait_mnibble(laplink_state *st, uint8 *v); + +// byte mode +extern status_t ll_send_byte(laplink_state *st, uint8 v); +extern status_t ll_check_byte(laplink_state *st, uint8 *v); +extern status_t ll_wait_byte(laplink_state *st, uint8 *v); + +// frame mode +extern status_t ll_send_frame(laplink_state *st, const uint8 *buff, size_t *len); +extern status_t ll_check_frame(laplink_state *st, uint8 *buff, size_t *len); +extern status_t ll_wait_frame(laplink_state *st, uint8 *buff, size_t *len); + + From mmu_man at mail.berlios.de Fri Feb 22 01:09:06 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 22 Feb 2008 01:09:06 +0100 Subject: [Haiku-commits] r24056 - in haiku/trunk/src/add-ons/kernel/debugger: bochs laplinkll Message-ID: <200802220009.m1M096f0002779@sheep.berlios.de> Author: mmu_man Date: 2008-02-22 01:09:05 +0100 (Fri, 22 Feb 2008) New Revision: 24056 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24056&view=rev Modified: haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp Log: * bochs module shouldn't load by default * made laplinkll module buildable, untested. Still requires a driver on the other box I need to port from zeta. Modified: haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp 2008-02-21 23:36:59 UTC (rev 24055) +++ haiku/trunk/src/add-ons/kernel/debugger/bochs/bochs.cpp 2008-02-22 00:09:05 UTC (rev 24056) @@ -28,7 +28,7 @@ std_ops(int32 op, ...) { void *handle; - bool load = true;//false; + bool load = false; switch (op) { case B_MODULE_INIT: Modified: haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile 2008-02-21 23:36:59 UTC (rev 24055) +++ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/Jamfile 2008-02-22 00:09:05 UTC (rev 24056) @@ -3,5 +3,5 @@ UsePrivateHeaders kernel ; KernelAddon laplinkll : - laplinkll.c + laplinkll.cpp ; Modified: haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp 2008-02-21 23:36:59 UTC (rev 24055) +++ haiku/trunk/src/add-ons/kernel/debugger/laplinkll/laplinkll.cpp 2008-02-22 00:09:05 UTC (rev 24056) @@ -43,23 +43,25 @@ st_error }; +static isa_module_info *sISAModule; + #pragma mark // raw access static inline uint8 read_status(uint32 port) { uint8 val; - val = read_io_8(port+1); + val = sISAModule->read_io_8(port+1); return val; } static inline void write_control(uint32 port, uint8 val) { - write_io_8(port+2, val); + sISAModule->write_io_8(port+2, val); } static inline void write_data(uint32 port, uint8 val) { - write_io_8(port, val); + sISAModule->write_io_8(port, val); } #pragma mark // framing @@ -381,7 +383,7 @@ static size_t laplink_in_avail; static char laplink_out_buf[BUFFSZ]; - +//XXX: cleanup static status_t debug_init_laplink(void *kernel_settings) { (void)kernel_settings; @@ -415,7 +417,7 @@ tries = 5; do { len = count; - err = ll_send_frame(&llst, buf, &len); + err = ll_send_frame(&llst, (const uint8 *)buf, &len); } while (err && tries--); if (err) return 0; @@ -428,7 +430,7 @@ while (laplink_in_avail < 1) { laplink_in_avail = BUFFSZ; laplink_in_ptr = laplink_in_buf; - err = ll_wait_frame(&llst, laplink_in_buf, &laplink_in_avail); + err = ll_wait_frame(&llst, (uint8 *)laplink_in_buf, &laplink_in_avail); if (err) laplink_in_avail = 0; } @@ -437,16 +439,58 @@ } -kdebug_io_handler laplink_debug_io = { - "laplink", - debug_init_laplink, - debug_write_laplink, - debug_read_laplink, +static int +debugger_puts(const char *s, int32 length) +{ + return debug_write_laplink(0, s, (int)length); +} + + +static status_t +std_ops(int32 op, ...) +{ + void *handle; + bool load = true;//false; + + switch (op) { + case B_MODULE_INIT: + handle = load_driver_settings("kernel"); + if (handle) { + load = get_driver_boolean_parameter(handle, + "laplinkll_debug_output", load, true); + unload_driver_settings(handle); + } + if (load) { + if (get_module(B_ISA_MODULE_NAME, (module_info **)&sISAModule) < B_OK) + return B_ERROR; + debug_init_laplink(NULL); + } + return load ? B_OK : B_ERROR; + case B_MODULE_UNINIT: + put_module(B_ISA_MODULE_NAME); + return B_OK; + } + return B_BAD_VALUE; +} + + +static struct debugger_module_info sModuleInfo = { + { + "debugger/laplinkll/v1", + 0, + &std_ops + }, NULL, NULL, + debugger_puts, NULL }; +module_info *modules[] = { + (module_info *)&sModuleInfo, + NULL +}; + #endif From axeld at mail.berlios.de Fri Feb 22 11:10:42 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 22 Feb 2008 11:10:42 +0100 Subject: [Haiku-commits] r24057 - in haiku/trunk/src/bin/sed: lib sed Message-ID: <200802221010.m1MAAgOK020362@sheep.berlios.de> Author: axeld Date: 2008-02-22 11:10:41 +0100 (Fri, 22 Feb 2008) New Revision: 24057 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24057&view=rev Modified: haiku/trunk/src/bin/sed/lib/Jamfile haiku/trunk/src/bin/sed/sed/Jamfile Log: Allow to build "sed" for BeOS; it's needed to make the AddSourceDirectoryToHaikuImage work there (it currently only works on Linux). Modified: haiku/trunk/src/bin/sed/lib/Jamfile =================================================================== --- haiku/trunk/src/bin/sed/lib/Jamfile 2008-02-22 00:09:05 UTC (rev 24056) +++ haiku/trunk/src/bin/sed/lib/Jamfile 2008-02-22 10:10:41 UTC (rev 24057) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src bin sed lib ; +SetSubDirSupportedPlatformsBeOSCompatible ; + SubDirCcFlags -DHAVE_CONFIG_H -w ; SubDirSysHdrs $(SUBDIR) ; SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ; Modified: haiku/trunk/src/bin/sed/sed/Jamfile =================================================================== --- haiku/trunk/src/bin/sed/sed/Jamfile 2008-02-22 00:09:05 UTC (rev 24056) +++ haiku/trunk/src/bin/sed/sed/Jamfile 2008-02-22 10:10:41 UTC (rev 24057) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src bin sed sed ; +SetSubDirSupportedPlatformsBeOSCompatible ; + SubDirCcFlags -I ../lib -DHAVE_CONFIG_H -DLOCALEDIR=\'\"/share/locale\"\' -w ; SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) lib ] ; SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ; From axeld at mail.berlios.de Fri Feb 22 11:33:43 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 22 Feb 2008 11:33:43 +0100 Subject: [Haiku-commits] r24058 - in haiku/trunk/build: jam scripts Message-ID: <200802221033.m1MAXhTo022400@sheep.berlios.de> Author: axeld Date: 2008-02-22 11:33:43 +0100 (Fri, 22 Feb 2008) New Revision: 24058 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24058&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/scripts/build_haiku_image Log: * Added new rule AddHeaderDirectoryToHaikuImage that copies header directories. Note that you need an updated "sed" (from the Haiku repository) if you want to use that rule. * The "Development" optional package now installs the Haiku headers needed to build stuff (ie. "os", "gnu", and "posix"). It also makes a symlink "be" so that we can still use the BeOS compiler with its builtin header paths. * Fixed AddVariableToScript for older shells that do not support '+='. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-22 10:10:41 UTC (rev 24057) +++ haiku/trunk/build/jam/HaikuImage 2008-02-22 10:33:43 UTC (rev 24058) @@ -501,6 +501,14 @@ # cc and c++ wrapper scripts AddFilesToHaikuImage beos bin : cc c++ ; + + # headers + AddHeaderDirectoryToHaikuImage gnu ; + AddHeaderDirectoryToHaikuImage os ; + AddHeaderDirectoryToHaikuImage posix ; + + # make be -> os symlink for now + AddSymlinkToHaikuImage develop headers : /boot/develop/headers/os : be ; } # Vision @@ -596,6 +604,8 @@ AddTargetVariableToScript $(script) : vmdkheader ; AddVariableToScript $(script) : sourceDirsToCopy : $(HAIKU_INSTALL_SOURCE_DIRS) ; +AddVariableToScript $(script) : headerDirsToCopy + : $(HAIKU_INSTALL_HEADER_DIRS) ; # create the other scripts HAIKU_IMAGE_MAKE_DIRS_SCRIPT = haiku.image-make-dirs ; Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2008-02-22 10:10:41 UTC (rev 24057) +++ haiku/trunk/build/jam/ImageRules 2008-02-22 10:33:43 UTC (rev 24058) @@ -58,7 +58,7 @@ value = $(value[2-]) ; while $(value) { VARIABLE_DEFS on $(script) - += "echo $(variable)+=\\\" $(value[1])\\\" >> " ; + += "echo $(variable)=\\\" \\\$$(variable) $(value[1])\\\" >> " ; value = $(value[2-]) ; } @@ -546,6 +546,17 @@ } } +rule AddHeaderDirectoryToHaikuImage dirTokens : alwaysUpdate +{ + # AddHeaderDirectoryToHaikuImage : ; + + # If the image shall only be updated, we update sources only, if explicitely + # requested. + if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) { + HAIKU_INSTALL_HEADER_DIRS += [ FDirName $(HAIKU_TOP) headers $(dirTokens) ] ; + } +} + rule UnzipArchiveToHaikuImage dirTokens : zipFile : alwaysUpdate { # UnzipArchiveToHaikuImage : : ; Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2008-02-22 10:10:41 UTC (rev 24057) +++ haiku/trunk/build/scripts/build_haiku_image 2008-02-22 10:33:43 UTC (rev 24058) @@ -10,6 +10,7 @@ # imageSize # addBuildCompatibilityLibDir # sourceDirsToCopy +# headerDirsToCopy # updateOnly # dontClearImage # isVMwareImage @@ -212,7 +213,7 @@ fi for sourcesDir in ${sourceDirsToCopy}; do - echo " sources dir: ${sourcesDir}" + echo " sources dir: ${sourcesDir}" # create all subdirectories subDirs=$(find ${sourcesDir} -type d | grep -v '.svn' | @@ -229,6 +230,43 @@ done +# install headers + +headersDest=${tPrefix}develop + +# create headers directory +if [ -n "${headerDirsToCopy}" ]; then + echo "Installing Haiku Headers ..." + + $mkdir -p ${headersDest} +fi + +# See above (sourceDirs) +sourcePathPrefix=$sourceDir +destPathPrefix=$headersDest +if [ $sourcePathPrefix = "." ]; then + sourcePathPrefix="" + destPathPrefix="${headersDest}/" +fi + +for headersDir in ${headerDirsToCopy}; do + echo " header dir: ${headersDir}" + + # create all subdirectories + subDirs=$(find ${headersDir} -type d | grep -v '.svn' | + sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") + $mkdir -p ${subDirs} + + # get all files and copy each one individually + headerFiles=$(find $headersDir -type f | grep -v '.svn') + for headerFile in $headerFiles; do + destHeaderFile=$(echo $headerFile | + sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@") + $cp ${sPrefix}$headerFile $destHeaderFile + done +done + + # unmount if [ $isImage ]; then echo "Unmounting ..." From axeld at mail.berlios.de Fri Feb 22 11:53:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 22 Feb 2008 11:53:27 +0100 Subject: [Haiku-commits] r24059 - haiku/trunk/headers/private/input Message-ID: <200802221053.m1MArRV7025640@sheep.berlios.de> Author: axeld Date: 2008-02-22 11:53:27 +0100 (Fri, 22 Feb 2008) New Revision: 24059 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24059&view=rev Modified: haiku/trunk/headers/private/input/kb_mouse_settings.h Log: Slightly increased the default key repeat rate to make it at least bearable. Modified: haiku/trunk/headers/private/input/kb_mouse_settings.h =================================================================== --- haiku/trunk/headers/private/input/kb_mouse_settings.h 2008-02-22 10:33:43 UTC (rev 24058) +++ haiku/trunk/headers/private/input/kb_mouse_settings.h 2008-02-22 10:53:27 UTC (rev 24059) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _KB_MOUSE_SETTINGS_H @@ -15,7 +15,7 @@ } kb_settings; #define kb_default_key_repeat_delay 500000 -#define kb_default_key_repeat_rate 200 +#define kb_default_key_repeat_rate 250 #define kb_settings_file "Keyboard_settings" From mmu_man at mail.berlios.de Fri Feb 22 13:05:05 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 22 Feb 2008 13:05:05 +0100 Subject: [Haiku-commits] r24060 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam Message-ID: <200802221205.m1MC55ha009789@sheep.berlios.de> Author: mmu_man Date: 2008-02-22 13:05:03 +0100 (Fri, 22 Feb 2008) New Revision: 24060 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24060&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp Log: fInternalIDCounter wasn't initialized; add debug info... it is triggering an ASSERT in media_addon_server though, about the flavor_id. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-02-22 10:53:27 UTC (rev 24059) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-02-22 12:05:03 UTC (rev 24060) @@ -17,6 +17,7 @@ fRoster(NULL) { PRINT((CH "()" CT)); + fInternalIDCounter = 0; /* Customize these parameters to match those of your node */ fMediaFormat.type = B_MEDIA_RAW_VIDEO; fMediaFormat.u.raw_video = media_raw_video_format::wildcard; @@ -92,7 +93,7 @@ if (cam && cam->FlavorInfo()) *out_info = cam->FlavorInfo(); fRoster->Unlock(); - PRINT((CH ": returning flavor for %d" CT, n)); + PRINT((CH ": returning flavor for %d, internal_id %d" CT, n, (*out_info)->internal_id)); return B_OK; } From aldeck at mail.berlios.de Fri Feb 22 14:36:51 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Fri, 22 Feb 2008 14:36:51 +0100 Subject: [Haiku-commits] r24061 - haiku/trunk/src/apps/glteapot Message-ID: <200802221336.m1MDap7B005062@sheep.berlios.de> Author: aldeck Date: 2008-02-22 14:36:50 +0100 (Fri, 22 Feb 2008) New Revision: 24061 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24061&view=rev Modified: haiku/trunk/src/apps/glteapot/ObjectView.cpp haiku/trunk/src/apps/glteapot/ObjectView.h Log: - rewrote/enhanced mouse tracking Modified: haiku/trunk/src/apps/glteapot/ObjectView.cpp =================================================================== --- haiku/trunk/src/apps/glteapot/ObjectView.cpp 2008-02-22 12:05:03 UTC (rev 24060) +++ haiku/trunk/src/apps/glteapot/ObjectView.cpp 2008-02-22 13:36:50 UTC (rev 24061) @@ -139,6 +139,14 @@ fLastYXRatio(1), fYxRatio(1) { + fTrackingInfo.isTracking = false; + fTrackingInfo.pickedObject = NULL; + fTrackingInfo.buttons = 0; + fTrackingInfo.lastX = 0.0f; + fTrackingInfo.lastY = 0.0f; + fTrackingInfo.lastDx = 0.0f; + fTrackingInfo.lastDy = 0.0f; + fLastObjectDistance = fObjectDistance = depthOfView/8; quittingSem = create_sem(1,"quitting sem"); drawEvent = create_sem(0,"draw event"); @@ -392,102 +400,108 @@ void -ObjectView::MouseDown(BPoint p) +ObjectView::MouseDown(BPoint point) { - BPoint op = p, np = p; - BRect bounds = Bounds(); - float lastDx = 0,lastDy = 0; - GLObject* o = NULL; - uint32 mods; + GLObject* object = NULL; - BMessage *m = Window()->CurrentMessage(); - uint32 buttons = m->FindInt32("buttons"); - o = ((GLObject*)fObjects.ItemAt(ObjectAtPoint(p))); + BMessage *msg = Window()->CurrentMessage(); + uint32 buttons = msg->FindInt32("buttons"); + object = ((GLObject*)fObjects.ItemAt(ObjectAtPoint(point))); - long locks = 0; - - while (Window()->IsLocked()) { - locks++; - Window()->Unlock(); - } + if (object != NULL){ + if (buttons == B_PRIMARY_MOUSE_BUTTON || buttons == B_SECONDARY_MOUSE_BUTTON) { + fTrackingInfo.pickedObject = object; + fTrackingInfo.buttons = buttons; + fTrackingInfo.isTracking = true; + fTrackingInfo.lastX = point.x; + fTrackingInfo.lastY = point.y; + fTrackingInfo.lastDx = 0.0f; + fTrackingInfo.lastDy = 0.0f; + fTrackingInfo.pickedObject->spinX = 0.0f; + fTrackingInfo.pickedObject->spinY = 0.0f; + + SetMouseEventMask(B_POINTER_EVENTS, + B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY); + } else { + ConvertToScreen(&point); + object->MenuInvoked(point); + } + } +} - if (buttons == B_SECONDARY_MOUSE_BUTTON) { - if (o) { - while (buttons) { - lastDx = np.x - op.x; - lastDy = np.y - op.y; - - if (lastDx || lastDy) { - float xinc = (lastDx * 2 * displayScale / bounds.Width()); - float yinc = (-lastDy * 2 * displayScale / bounds.Height()); - float zinc = 0; - - if (fPersp) { - zinc = yinc * (o->z / displayScale); - xinc *= -(o->z * 4 / zRatio); - yinc *= -(o->z * 4 / zRatio); - } - o->x += xinc; - mods = modifiers(); - if (mods & B_SHIFT_KEY) - o->z += zinc; - else - o->y += yinc; - op = np; - fForceRedraw = true; - setEvent(drawEvent); - } - snooze(25000); - - Window()->Lock(); - GetMouse(&np, &buttons, true); - Window()->Unlock(); - } +void +ObjectView::MouseUp(BPoint point) +{ + if (fTrackingInfo.isTracking) { + + //spin the teapot on release, TODO: use a marching sum and divide by time + if (fTrackingInfo.buttons == B_PRIMARY_MOUSE_BUTTON + && fTrackingInfo.pickedObject != NULL + && (fabs(fTrackingInfo.lastDx) > 1.0f + || fabs(fTrackingInfo.lastDy) > 1.0f) ) { + + fTrackingInfo.pickedObject->spinX = 0.5f * fTrackingInfo.lastDy; + fTrackingInfo.pickedObject->spinY = 0.5f * fTrackingInfo.lastDx; + + setEvent(drawEvent); } - } else if (buttons == B_PRIMARY_MOUSE_BUTTON) { - float llx = 0, lly = 0; - lastDx = lastDy = 0; - if (o) { - o->spinX = 0; - o->spinY = 0; - while (buttons) { - llx = lastDx; - lly = lastDy; - lastDx = np.x - op.x; - lastDy = np.y - op.y; - - if (lastDx || lastDy) { - o->rotY += lastDx; - o->rotX += lastDy; - op = np; - setEvent(drawEvent); - } + //stop tracking + fTrackingInfo.isTracking = false; + fTrackingInfo.buttons = 0; + fTrackingInfo.pickedObject = NULL; + fTrackingInfo.lastX = 0.0f; + fTrackingInfo.lastY = 0.0f; + fTrackingInfo.lastDx = 0.0f; + fTrackingInfo.lastDy = 0.0f; + } +} - snooze(25000); - Window()->Lock(); - GetMouse(&np, &buttons, true); - Window()->Unlock(); +void +ObjectView::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) +{ + if (fTrackingInfo.isTracking && fTrackingInfo.pickedObject != NULL) { + + float dx = point.x - fTrackingInfo.lastX; + float dy = point.y - fTrackingInfo.lastY; + fTrackingInfo.lastX = point.x; + fTrackingInfo.lastY = point.y; + + if (fTrackingInfo.buttons == B_PRIMARY_MOUSE_BUTTON) { + + fTrackingInfo.pickedObject->spinX = 0; + fTrackingInfo.pickedObject->spinY = 0; + fTrackingInfo.pickedObject->rotY += dx; + fTrackingInfo.pickedObject->rotX += dy; + fTrackingInfo.lastDx = dx; + fTrackingInfo.lastDy = dy; + + setEvent(drawEvent); + + } else if (fTrackingInfo.buttons == B_SECONDARY_MOUSE_BUTTON) { + + float xinc = (dx * 2 * displayScale / Bounds().Width()); + float yinc = (-dy * 2 * displayScale / Bounds().Height()); + float zinc = 0; + + if (fPersp) { + zinc = yinc * (fTrackingInfo.pickedObject->z / displayScale); + xinc *= -(fTrackingInfo.pickedObject->z * 4 / zRatio); + yinc *= -(fTrackingInfo.pickedObject->z * 4 / zRatio); } - o->spinY = lastDx + llx; - o->spinX = lastDy + lly; - } - } else { - if (o) { - BPoint point = p; - Window()->Lock(); - ConvertToScreen(&point); - Window()->Unlock(); - o->MenuInvoked(point); - } - } - - while (locks--) - Window()->Lock(); - - setEvent(drawEvent); + + fTrackingInfo.pickedObject->x += xinc; + if (modifiers() & B_SHIFT_KEY) + fTrackingInfo.pickedObject->z += zinc; + else + fTrackingInfo.pickedObject->y += yinc; + + fForceRedraw = true; + setEvent(drawEvent); + } + } } Modified: haiku/trunk/src/apps/glteapot/ObjectView.h =================================================================== --- haiku/trunk/src/apps/glteapot/ObjectView.h 2008-02-22 12:05:03 UTC (rev 24060) +++ haiku/trunk/src/apps/glteapot/ObjectView.h 2008-02-22 13:36:50 UTC (rev 24061) @@ -33,7 +33,18 @@ #define HISTSIZE 10 class ResScroll; +class GLObject; +struct TrackingInfo { + float lastX; + float lastY; + float lastDx; + float lastDy; + bool isTracking; + GLObject *pickedObject; + uint32 buttons; +}; + class ObjectView : public BGLView { public: ObjectView(BRect r, char* name, ulong resizingMode, @@ -41,6 +52,9 @@ ~ObjectView(); virtual void MouseDown(BPoint p); + virtual void MouseUp(BPoint p); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg); + virtual void MessageReceived(BMessage* msg); virtual void AttachedToWindow(); virtual void DetachedFromWindow(); @@ -69,6 +83,7 @@ bool fLastFog, fFog, fForceRedraw; float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE]; float fObjectDistance,fLastObjectDistance; + TrackingInfo fTrackingInfo; }; #endif // OBJECT_VIEW_H From axeld at mail.berlios.de Fri Feb 22 15:18:57 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 22 Feb 2008 15:18:57 +0100 Subject: [Haiku-commits] r24062 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 Message-ID: <200802221418.m1MEIvVa011316@sheep.berlios.de> Author: axeld Date: 2008-02-22 15:18:56 +0100 (Fri, 22 Feb 2008) New Revision: 24062 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24062&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/driver.c Log: * Added another device ID to the driver (0x8168). * A bit of refactoring to let the driver more easily accept more devices. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/driver.c 2008-02-22 13:36:50 UTC (rev 24061) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/driver.c 2008-02-22 14:18:56 UTC (rev 24062) @@ -30,34 +30,78 @@ #include "setup.h" #include "timer.h" + +#define VENDOR_ID_REALTEK 0x10ec + + +static const uint32 kSupportedDevices[] = { + 0x8167, + 0x8168, + 0x8169, +}; + int32 api_version = B_CUR_DRIVER_API_VERSION; -pci_module_info *gPci; - char* gDevNameList[MAX_CARDS + 1]; pci_info *gDevList[MAX_CARDS]; +pci_module_info *gPci; +static device_hooks sDeviceHooks = { + rtl8169_open, + rtl8169_close, + rtl8169_free, + rtl8169_control, + rtl8169_read, + rtl8169_write, +}; + + +static status_t +get_next_supported_pci_info(int32 *_cookie, pci_info *info) +{ + int32 index = *_cookie; + uint32 i; + + // find devices + + for (; gPci->get_nth_pci_info(index, info) == B_OK; index++) { + // check vendor + if (info->vendor_id != VENDOR_ID_REALTEK) + continue; + + // check device + for (i = 0; i < sizeof(kSupportedDevices) + / sizeof(kSupportedDevices[0]); i++) { + if (info->device_id == kSupportedDevices[i]) { + *_cookie = index + 1; + return B_OK; + } + } + } + + return B_ENTRY_NOT_FOUND; +} + + +// #pragma mark - + + status_t init_hardware(void) { - pci_module_info *pci; + uint32 cookie = 0; + status_t result; pci_info info; - status_t res; - int i; TRACE("init_hardware()\n"); - if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci) < B_OK) + if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) return B_ERROR; - for (res = B_ERROR, i = 0; pci->get_nth_pci_info(i, &info) == B_OK; i++) { - if (info.vendor_id == 0x10ec && (info.device_id == 0x8169 || info.device_id == 0x8167)) { - res = B_OK; - break; - } - } + + result = get_next_supported_pci_info(&cookie, &info); put_module(B_PCI_MODULE_NAME); - return res; + return result; } @@ -65,8 +109,8 @@ init_driver(void) { struct pci_info *item; - int index; - int cards; + uint32 index = 0; + int cards = 0; #ifdef DEBUG set_dprintf_enabled(true); @@ -84,21 +128,21 @@ free(item); return B_ERROR; } - - for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) { - if (item->vendor_id == 0x10ec && (item->device_id == 0x8169 || item->device_id == 0x8167)) { - char name[64]; - sprintf(name, "net/rtl8169/%d", cards); - gDevList[cards] = item; - gDevNameList[cards] = strdup(name); - gDevNameList[cards + 1] = NULL; - cards++; - item = (pci_info *)malloc(sizeof(pci_info)); - if (!item) - goto err_outofmem; - if (cards == MAX_CARDS) - break; - } + + while (get_next_supported_pci_info(&index, item) == B_OK) { + char name[64]; + sprintf(name, "net/rtl8169/%d", cards); + gDevList[cards] = item; + gDevNameList[cards] = strdup(name); + gDevNameList[cards + 1] = NULL; + cards++; + + item = (pci_info *)malloc(sizeof(pci_info)); + if (!item) + goto err_outofmem; + + if (cards == MAX_CARDS) + break; } TRACE("found %d cards\n", cards); @@ -133,29 +177,18 @@ int32 i; TRACE("uninit_driver()\n"); - + terminate_timer(); for (i = 0; gDevNameList[i] != NULL; i++) { free(gDevList[i]); free(gDevNameList[i]); } - + put_module(B_PCI_MODULE_NAME); } -device_hooks -gDeviceHooks = { - rtl8169_open, - rtl8169_close, - rtl8169_free, - rtl8169_control, - rtl8169_read, - rtl8169_write, -}; - - const char** publish_devices() { @@ -166,5 +199,5 @@ device_hooks* find_device(const char* name) { - return &gDeviceHooks; + return &sDeviceHooks; } From bonefish at mail.berlios.de Fri Feb 22 15:51:12 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 22 Feb 2008 15:51:12 +0100 Subject: [Haiku-commits] r24063 - haiku/trunk/src/system/kernel Message-ID: <200802221451.m1MEpCHi014796@sheep.berlios.de> Author: bonefish Date: 2008-02-22 15:51:11 +0100 (Fri, 22 Feb 2008) New Revision: 24063 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24063&view=rev Modified: haiku/trunk/src/system/kernel/condition_variable.cpp Log: We have to remove the thread's condition variable entries when interrupted early, i.e. when signals were already pending when we started waiting. Fixes #1832. Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2008-02-22 14:18:56 UTC (rev 24062) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2008-02-22 14:51:11 UTC (rev 24063) @@ -162,6 +162,12 @@ && (thread->sig_pending & ~thread->sig_block_mask) != 0) || ((flags & B_KILL_CAN_INTERRUPT) && (thread->sig_pending & KILL_SIGNALS))) { + // remove all of the thread's entries from their variables + entry = firstEntry; + while (entry) { + entry->_Remove(); + entry = entry->fThreadNext; + } return B_INTERRUPTED; } From bonefish at mail.berlios.de Fri Feb 22 15:54:03 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 22 Feb 2008 15:54:03 +0100 Subject: [Haiku-commits] r24064 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/arch/x86 Message-ID: <200802221454.m1MEs3th014952@sheep.berlios.de> Author: bonefish Date: 2008-02-22 15:54:03 +0100 (Fri, 22 Feb 2008) New Revision: 24064 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24064&view=rev Modified: haiku/trunk/headers/private/kernel/ksignal.h haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp haiku/trunk/src/system/kernel/signal.cpp Log: We have to update the pending signals thread flag when restoring the signal block mask when returning from a signal handler. Modified: haiku/trunk/headers/private/kernel/ksignal.h =================================================================== --- haiku/trunk/headers/private/kernel/ksignal.h 2008-02-22 14:51:11 UTC (rev 24063) +++ haiku/trunk/headers/private/kernel/ksignal.h 2008-02-22 14:54:03 UTC (rev 24064) @@ -29,6 +29,8 @@ extern int has_signals_pending(void *_thread); extern bool is_signal_blocked(int signal); +extern void update_current_thread_signals_flag(); + extern int sigaction_etc(thread_id threadID, int signal, const struct sigaction *newAction, struct sigaction *oldAction); Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-22 14:51:11 UTC (rev 24063) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-02-22 14:54:03 UTC (rev 24064) @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -546,7 +547,11 @@ atomic_or(&thread->flags, threadFlags & (THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_64_BIT_SYSCALL_RETURN)); + // TODO: Verify that just restoring the old signal mask is right! Bash for + // instance changes the procmask in a signal handler. Those changes are + // lost the way we do it. atomic_set(&thread->sig_block_mask, signalMask); + update_current_thread_signals_flag(); frame->eip = regs.eip; frame->flags = regs.eflags; Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-02-22 14:51:11 UTC (rev 24063) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-02-22 14:54:03 UTC (rev 24064) @@ -197,7 +197,7 @@ } -static void +void update_current_thread_signals_flag() { InterruptsSpinLocker locker(thread_spinlock); From bonefish at mail.berlios.de Fri Feb 22 15:55:10 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 22 Feb 2008 15:55:10 +0100 Subject: [Haiku-commits] r24065 - haiku/trunk/src/system/kernel Message-ID: <200802221455.m1MEtAI6015017@sheep.berlios.de> Author: bonefish Date: 2008-02-22 15:55:10 +0100 (Fri, 22 Feb 2008) New Revision: 24065 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24065&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: "thread" also prints the signal block mask, now. Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-02-22 14:54:03 UTC (rev 24064) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-02-22 14:55:10 UTC (rev 24065) @@ -1025,7 +1025,8 @@ kprintf("(%d)\n", thread->cpu->cpu_num); else kprintf("\n"); - kprintf("sig_pending: %#lx\n", thread->sig_pending); + kprintf("sig_pending: %#lx (blocked: %#lx)\n", thread->sig_pending, + thread->sig_block_mask); kprintf("in_kernel: %d\n", thread->in_kernel); kprintf(" sem.blocking: %ld\n", thread->sem.blocking); kprintf(" sem.count: %ld\n", thread->sem.count); From axeld at mail.berlios.de Fri Feb 22 19:30:26 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 22 Feb 2008 19:30:26 +0100 Subject: [Haiku-commits] r24066 - haiku/trunk/src/tests/add-ons/kernel/drivers/audio Message-ID: <200802221830.m1MIUQUG023586@sheep.berlios.de> Author: axeld Date: 2008-02-22 19:30:25 +0100 (Fri, 22 Feb 2008) New Revision: 24066 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24066&view=rev Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp Log: * Now plays a recognizable tone instead (sinus) - took me a while to figure out that buffer exchange would return more often than it actually exchanged a buffer in hmulti_audio. * Implemented setters for commands "format", and "channel". * "play" now accepts a play mask to mute certain channels. Modified: haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp 2008-02-22 14:55:10 UTC (rev 24065) +++ haiku/trunk/src/tests/add-ons/kernel/drivers/audio/multi_audio_test.cpp 2008-02-22 18:30:25 UTC (rev 24066) @@ -59,7 +59,7 @@ static multi_channel_info sChannelInfo[MAX_CHANNELS]; static multi_description sDescription; static uint32 sRate = B_SR_48000; -static uint32 sFormat = B_FMT_32BIT;//B_FMT_FLOAT;//B_FMT_16BIT; +static uint32 sFormat = B_FMT_32BIT; static uint32 sEnabledChannels = ~0; @@ -169,6 +169,21 @@ static void do_format(int argc, char** argv) { + int32 i = -1; + if (argc == 2) + i = strtoll(argv[1], NULL, 0); + + if (i < 1 || i > (int32)(sizeof(kFormats) / sizeof(kFormats[0]))) { + if (argc == 2) + fprintf(stderr, "Invalid format: %ld\n", i); + + for (uint32 i = 0; i < sizeof(kFormats) / sizeof(kFormats[0]); i++) { + printf("[%ld] %s\n", i + 1, kFormats[i].name); + } + } else { + sFormat = kFormats[i - 1].type; + } + printf("Current sample format is %s (0x%lx)\n", get_format_name(sFormat), sFormat); } @@ -215,6 +230,9 @@ static void do_channels(int argc, char** argv) { + if (argc == 2) + sEnabledChannels = strtoul(argv[1], NULL, 0); + uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; printf("%ld channels:\n ", channel_count()); @@ -223,40 +241,16 @@ enabled >>= 1; } putchar('\n'); - -/* - sEnabledChannels = enabled; - - multi_channel_enable channelEnable; - uint32 enabled; - - channelEnable.info_size = sizeof(multi_channel_enable); - channelEnable.enable_bits = (uchar*)&enabled; - - if (ioctl(sDevice, B_MULTI_GET_ENABLED_CHANNELS, &channelEnable, - sizeof(channelEnable)) < B_OK) { - fprintf(stderr, "Failed on B_MULTI_GET_ENABLED_CHANNELS: %s\n", - strerror(errno)); - return; - } - - - multi_channel_enable channelEnable; - uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; - - channelEnable.lock_source = B_MULTI_LOCK_INTERNAL; - if (ioctl(sDevice, B_MULTI_SET_ENABLED_CHANNELS, &channelEnable, - sizeof(multi_channel_enable)) < B_OK) { - fprintf(stderr, "Setting enabled channels failed: %s\n", - strerror(errno)); - } -*/ } static void do_play(int argc, char** argv) { + uint32 playMask = 0xffffffff; + if (argc == 2) + playMask = strtoul(argv[1], NULL, 0); + multi_channel_enable channelEnable; uint32 enabled = ((1 << channel_count()) - 1) & sEnabledChannels; @@ -322,30 +316,28 @@ printf("playback: buffer count %ld, channels %ld, buffer size %ld\n", bufferList.return_playback_buffers, bufferList.return_playback_channels, bufferList.return_playback_buffer_size); + for (int32 channel = 0; channel < bufferList.return_playback_channels; + channel++) { + printf(" Channel %ld\n", channel); + for (int32 i = 0; i < bufferList.return_playback_buffers; i++) { + printf(" [%ld] buffer %p, stride %ld\n", i, + bufferList.playback_buffers[i][channel].base, + bufferList.playback_buffers[i][channel].stride); + } + } + printf("record: buffer count %ld, channels %ld, buffer size %ld\n", bufferList.return_record_buffers, bufferList.return_record_channels, bufferList.return_record_buffer_size); - // fill buffers with data - - for (int32 i = 0; i < bufferList.return_playback_buffers; i++) { - size_t stride = bufferList.playback_buffers[i][0].stride; - for (int32 channel = 0; channel < sDescription.output_channel_count; - channel++) { - char* dest = bufferList.playback_buffers[i][channel].base; - for (uint32 frame = 0; - frame < bufferList.return_playback_buffer_size; frame++) { - set_frame(dest, formatInfo.output.format, sin(frame / 1000.0)); - dest += stride; - } - } - } - multi_buffer_info bufferInfo; memset(&bufferInfo, 0, sizeof(multi_buffer_info)); bufferInfo.info_size = sizeof(multi_buffer_info); bigtime_t startTime = system_time(); + uint32 exchanged = 0; + uint32 cycle = ~0; + uint32 x = 0; while (true) { if (system_time() - startTime > 1000000LL) break; @@ -355,10 +347,37 @@ printf("Getting buffers failed: %s\n", strerror(errno)); } - bufferInfo.playback_buffer_cycle = (bufferInfo.playback_buffer_cycle + 1) - % bufferList.request_playback_buffers; + // fill buffer with data + + // Note: hmulti-audio drivers may actually return more than once + // per buffer... + if (cycle == bufferInfo.playback_buffer_cycle + && bufferList.return_playback_buffers != 1) + continue; + + cycle = bufferInfo.playback_buffer_cycle; + + size_t stride = bufferList.playback_buffers[cycle][0].stride; + for (int32 channel = 0; channel < bufferList.return_playback_channels; + channel++) { + if (((1 << channel) & playMask) == 0) + continue; + + char* dest = bufferList.playback_buffers[cycle][channel].base; + for (uint32 frame = 0; + frame < bufferList.return_playback_buffer_size; frame++) { + set_frame(dest, formatInfo.output.format, sin((x + frame) / 32.0)); + dest += stride; + } + } + + x += bufferList.return_playback_buffer_size; + exchanged++; } + printf("%ld buffers exchanged while playing (%lu frames played (%lu)).\n", + exchanged, x, bufferInfo.played_frames_count); + // clear buffers for (int32 i = 0; i < bufferList.return_playback_buffers; i++) { From korli at mail.berlios.de Fri Feb 22 19:39:40 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 22 Feb 2008 19:39:40 +0100 Subject: [Haiku-commits] r24067 - in haiku/trunk/src/add-ons/translators: . bmp exr hpgs ico pcx png raw rtf sgi shared stxt tga tiff wonderbrush Message-ID: <200802221839.m1MIdeSk024300@sheep.berlios.de> Author: korli Date: 2008-02-22 19:39:39 +0100 (Fri, 22 Feb 2008) New Revision: 24067 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24067&view=rev Added: haiku/trunk/src/add-ons/translators/shared/Jamfile Modified: haiku/trunk/src/add-ons/translators/Jamfile haiku/trunk/src/add-ons/translators/bmp/Jamfile haiku/trunk/src/add-ons/translators/exr/Jamfile haiku/trunk/src/add-ons/translators/hpgs/Jamfile haiku/trunk/src/add-ons/translators/ico/Jamfile haiku/trunk/src/add-ons/translators/pcx/Jamfile haiku/trunk/src/add-ons/translators/png/Jamfile haiku/trunk/src/add-ons/translators/raw/Jamfile haiku/trunk/src/add-ons/translators/rtf/Jamfile haiku/trunk/src/add-ons/translators/sgi/Jamfile haiku/trunk/src/add-ons/translators/stxt/Jamfile haiku/trunk/src/add-ons/translators/tga/Jamfile haiku/trunk/src/add-ons/translators/tiff/Jamfile haiku/trunk/src/add-ons/translators/wonderbrush/Jamfile Log: added libtranslatorsutils.a and used it in every translator instead of reusing sources Modified: haiku/trunk/src/add-ons/translators/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -13,6 +13,7 @@ SubInclude HAIKU_TOP src add-ons translators raw ; SubInclude HAIKU_TOP src add-ons translators rtf ; SubInclude HAIKU_TOP src add-ons translators sgi ; +SubInclude HAIKU_TOP src add-ons translators shared ; SubInclude HAIKU_TOP src add-ons translators stxt ; SubInclude HAIKU_TOP src add-ons translators tga ; SubInclude HAIKU_TOP src add-ons translators tiff ; Modified: haiku/trunk/src/add-ons/translators/bmp/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/bmp/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/bmp/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,21 +2,14 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator BMPTranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - # BMPTranslator classes BMPMain.cpp BMPTranslator.cpp BMPView.cpp - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/exr/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/exr/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -5,8 +5,7 @@ SubDirSysHdrs [ FDirName $(SUBDIR) openexr ilmimf ] ; SubDirSysHdrs [ FDirName $(SUBDIR) openexr imath ] ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator EXRTranslator : main.cpp @@ -14,13 +13,7 @@ EXRGamma.cpp EXRTranslator.cpp IStreamWrapper.cpp - - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - : be translation libilmimf.so $(TARGET_LIBSTDC++) + : be translation libilmimf.so $(TARGET_LIBSTDC++) libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/hpgs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/hpgs/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/hpgs/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -3,10 +3,8 @@ SubDirSysHdrs [ FDirName $(SUBDIR) lib ] ; SubDirCcFlags -DHPGS_SHARED -std=c99 ; UseLibraryHeaders zlib png ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; - local sources = hpgsbase.c hpgsbbox.c @@ -46,13 +44,7 @@ ConfigView.cpp HPGSTranslator.cpp $(sources) - - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - : be translation libpng.so libtextencoding.so libz.so + : be translation libpng.so libtextencoding.so libz.so libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/ico/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/ico/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/ico/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,8 +2,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator ICOTranslator : # ICOTranslator classes @@ -11,13 +10,7 @@ ICOTranslator.cpp ConfigView.cpp ICO.cpp - - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/pcx/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/pcx/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,8 +2,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator PCXTranslator : # PCXTranslator classes @@ -11,13 +10,7 @@ PCXTranslator.cpp ConfigView.cpp PCX.cpp - - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/png/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/png/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/png/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,24 +2,15 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -UseLibraryHeaders zlib ; -UseLibraryHeaders png ; +UseLibraryHeaders png zlib ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; - Translator PNGTranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - # PNGTranslator classes PNGMain.cpp PNGTranslator.cpp PNGView.cpp - : be translation libpng.a z + : be translation libpng.a z libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/raw/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/raw/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/raw/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,8 +2,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator RAWTranslator : # RawTranslator classes @@ -11,13 +10,7 @@ RAWTranslator.cpp ConfigView.cpp RAW.cpp - - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/rtf/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/rtf/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/rtf/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,13 +2,12 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include code from shared translator directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; - # It's called RTF-Translator (with a dash) to differentiate it from the # RTFTranslator that comes with Gobe Productive (that doesn't support # STXT or plain text files output). +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; + Translator RTF-Translator : # RTFTranslator classes main.cpp @@ -16,11 +15,7 @@ ConfigView.cpp RTF.cpp convert.cpp - - # shared classes - TranslatorWindow.cpp - - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/sgi/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/sgi/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/sgi/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,22 +2,15 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator SGITranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - # SGITranslator classes SGIImage.cpp SGIMain.cpp SGITranslator.cpp SGIView.cpp - : be translation + : be translation libtranslatorsutils.a : true ; Added: haiku/trunk/src/add-ons/translators/shared/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/shared/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/shared/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src add-ons translators shared ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +StaticLibrary libtranslatorsutils.a : + BaseTranslator.cpp + StreamBuffer.cpp + TranslatorSettings.cpp + TranslatorWindow.cpp + ; Modified: haiku/trunk/src/add-ons/translators/stxt/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/stxt/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/stxt/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -6,21 +6,13 @@ UseHeaders [ FDirName $(HAIKU_TOP) src servers registrar ] ; # for the text identification -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator STXTTranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - # STXTTranslator classes STXTMain.cpp STXTTranslator.cpp STXTView.cpp - - : be translation libtextencoding.so + : be translation libtextencoding.so libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/tga/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/tga/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/tga/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,22 +2,13 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator TGATranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - StreamBuffer.cpp - - # TGATranslator classes TGAMain.cpp TGATranslator.cpp TGAView.cpp - - : be translation + : be translation libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/tiff/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/tiff/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/tiff/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -4,8 +4,7 @@ UseLibraryHeaders zlib ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; local tiff_files = # libtiff @@ -50,17 +49,12 @@ Translator TIFFTranslator : [ FGristFiles $(tiff_files:S=$(SUFOBJ)) ] - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - # TIFFTranslator classes TIFFMain.cpp TIFFTranslator.cpp TIFFView.cpp - : be translation z + : be translation z libtranslatorsutils.a : true ; Modified: haiku/trunk/src/add-ons/translators/wonderbrush/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/wonderbrush/Jamfile 2008-02-22 18:30:25 UTC (rev 24066) +++ haiku/trunk/src/add-ons/translators/wonderbrush/Jamfile 2008-02-22 18:39:39 UTC (rev 24067) @@ -2,21 +2,13 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -# Include BaseTranslator code from shared directory -SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ; - # Include support sub folder SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators wonderbrush support ] ; UseLibraryHeaders zlib ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; Translator WonderBrushTranslator : - # shared classes - BaseTranslator.cpp - TranslatorSettings.cpp - TranslatorWindow.cpp - - # WonderBrushTranslator classes Canvas.cpp Layer.cpp WonderBrushImage.cpp @@ -29,7 +21,7 @@ blending.cpp lab_convert.cpp - : be translation z + : be translation z libtranslatorsutils.a : true ; From korli at mail.berlios.de Fri Feb 22 22:21:40 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 22 Feb 2008 22:21:40 +0100 Subject: [Haiku-commits] r24068 - in haiku/trunk/src/add-ons/translators: pcx shared tga Message-ID: <200802222121.m1MLLduL010018@sheep.berlios.de> Author: korli Date: 2008-02-22 22:21:39 +0100 (Fri, 22 Feb 2008) New Revision: 24068 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24068&view=rev Modified: haiku/trunk/src/add-ons/translators/pcx/PCX.cpp haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h haiku/trunk/src/add-ons/translators/tga/TGATranslator.cpp Log: PCXTranslator now uses the StreamBuffer class fixed StreamBuffer::Read() to handle bigger reads added a write mode revised code style and license header Modified: haiku/trunk/src/add-ons/translators/pcx/PCX.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/pcx/PCX.cpp 2008-02-22 18:39:39 UTC (rev 24067) +++ haiku/trunk/src/add-ons/translators/pcx/PCX.cpp 2008-02-22 21:21:39 UTC (rev 24068) @@ -4,6 +4,7 @@ * Distributed under the terms of the MIT License. */ +#include "StreamBuffer.h" #include "PCX.h" #include "PCXTranslator.h" @@ -69,7 +70,7 @@ static status_t -convert_data_to_bits(pcx_header &header, BPositionIO &source, +convert_data_to_bits(pcx_header &header, StreamBuffer &source, BPositionIO &target) { uint16 bitsPerPixel = header.bitsPerPixel; @@ -224,8 +225,12 @@ status_t PCX::convert_pcx_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target) { + StreamBuffer sourceBuf(&source, 2048); + if (sourceBuf.InitCheck() != B_OK) + return B_IO_ERROR; + pcx_header header; - if (source.Read(&header, sizeof(pcx_header)) != (ssize_t)sizeof(pcx_header)) + if (sourceBuf.Read(&header, sizeof(pcx_header)) != (ssize_t)sizeof(pcx_header)) return B_BAD_VALUE; header.SwapToHost(); @@ -253,5 +258,5 @@ swap_data(B_UINT32_TYPE, &bitsHeader, sizeof(TranslatorBitmap), B_SWAP_HOST_TO_BENDIAN); target.Write(&bitsHeader, sizeof(TranslatorBitmap)); - return convert_data_to_bits(header, source, target); + return convert_data_to_bits(header, sourceBuf, target); } Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-22 18:39:39 UTC (rev 24067) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-22 21:21:39 UTC (rev 24068) @@ -1,37 +1,13 @@ -/*****************************************************************************/ -// StreamBuffer -// Written by Michael Wilber, OBOS Translation Kit Team -// -// StreamBuffer.cpp -// -// This class is for buffering data from a BPositionIO object in order to -// improve performance for cases when small amounts of data are frequently -// read from a BPositionIO object. -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2008, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors : + * Michael Wilber + * J?r?me Duval + */ #include -#include #include "StreamBuffer.h" #ifndef min @@ -61,25 +37,20 @@ // // Returns: // --------------------------------------------------------------- -StreamBuffer::StreamBuffer(BPositionIO *pstream, size_t nbuffersize, - bool binitialread) +StreamBuffer::StreamBuffer(BPositionIO *pstream, size_t nbuffersize, bool toRead) { - fpStream = pstream; - fpBuffer = NULL; - fnBufferSize = 0; - fnLen = 0; - fnPos = 0; + fStream = pstream; + fBuffer = NULL; + fBufferSize = 0; + fLen = 0; + fPos = 0; + fToRead = toRead; if (!pstream) return; - fnBufferSize = max(nbuffersize, MIN_BUFFER_SIZE); - fpBuffer = new uint8[fnBufferSize]; - if (fpBuffer && binitialread) - ReadStream(); - // Fill the buffer with data so that - // object is prepared for first call to - // Read() + fBufferSize = max(nbuffersize, MIN_BUFFER_SIZE); + fBuffer = new uint8[fBufferSize]; } // --------------------------------------------------------------- @@ -97,13 +68,10 @@ // --------------------------------------------------------------- StreamBuffer::~StreamBuffer() { - fnBufferSize = 0; - fnLen = 0; - fnPos = 0; - fpStream = NULL; - - delete[] fpBuffer; - fpBuffer = NULL; + if (!fToRead && fLen > 0) + fStream->Write(fBuffer, fLen); + delete[] fBuffer; + fBuffer = NULL; } // --------------------------------------------------------------- @@ -123,7 +91,7 @@ status_t StreamBuffer::InitCheck() { - if (fpStream && fpBuffer) + if (fStream && fBuffer) return B_OK; else return B_ERROR; @@ -147,38 +115,71 @@ // error code returned by BPositionIO::Read() // --------------------------------------------------------------- ssize_t -StreamBuffer::Read(uint8 *pinto, size_t nbytes) +StreamBuffer::Read(void *pinto, size_t nbytes) { + if (nbytes == 0) + return 0; + ssize_t result = B_ERROR; - size_t rd1 = 0, rd2 = 0; + + size_t totalRead = min(nbytes, fLen - fPos); + memcpy(pinto, fBuffer + fPos, totalRead); + fPos += totalRead; + (uint8 *)pinto += totalRead; + nbytes -= totalRead; - rd1 = min(nbytes, fnLen - fnPos); - memcpy(pinto, fpBuffer + fnPos, rd1); - fnPos += rd1; - - if (rd1 < nbytes) { - pinto += rd1; - result = ReadStream(); - if (result > 0) { - rd2 = min(nbytes - rd1, fnLen); - memcpy(pinto, fpBuffer, rd2); - fnPos += rd2; - } else - // return error code or zero + while (nbytes > 0) { + result = _ReadStream(); + if (result <= 0) return result; + if (result > 0) { + size_t left = min(nbytes, fLen - fPos); + memcpy(pinto, fBuffer + fPos, left); + fPos += left; + (uint8 *)pinto += left; + nbytes -= left; + totalRead += left; + } } - return rd1 + rd2; + return totalRead; } + // --------------------------------------------------------------- +// Write +// +// Copies up to nbytes of data from pinto into the stream +// +// Parameters: pinto, the buffer to be copied from +// nbytes, the maximum number of bytes to copy +// +// Returns: the number of bytes successfully read or an +// error code returned by BPositionIO::Read() +// --------------------------------------------------------------- +void +StreamBuffer::Write(void *pinto, size_t nbytes) +{ + if (nbytes < fBufferSize - fLen) { + memcpy(fBuffer + fLen, pinto, nbytes); + fLen += nbytes; + } else { + if (fLen > 0) { + fStream->Write(fBuffer, fLen); + fLen = 0; + } + fStream->Write(pinto, nbytes); + } +} + + +// --------------------------------------------------------------- // Seek // -// Seeks the stream to the given position and refreshes the -// read buffer. If the seek operation fails, the read buffer -// will be reset. +// Seeks the stream to the given position. If the seek operation fails, +// the read buffer will be reset. // -// Preconditions: fpBuffer must be allocated and fnBufferSize +// Preconditions: fBuffer must be allocated and fBufferSize // must be valid // // Parameters: @@ -191,11 +192,10 @@ bool StreamBuffer::Seek(off_t position) { - fnLen = 0; - fnPos = 0; + fLen = 0; + fPos = 0; - if (fpStream->Seek(position, SEEK_SET) == position) { - ReadStream(); + if (fStream->Seek(position, SEEK_SET) == position) { return true; } @@ -203,11 +203,11 @@ } // --------------------------------------------------------------- -// ReadStream +// _ReadStream // // Fills the stream buffer with data read in from the stream // -// Preconditions: fpBuffer must be allocated and fnBufferSize +// Preconditions: fBuffer must be allocated and fBufferSize // must be valid // // Parameters: @@ -218,13 +218,12 @@ // error code returned by BPositionIO::Read() // --------------------------------------------------------------- ssize_t -StreamBuffer::ReadStream() +StreamBuffer::_ReadStream() { - ssize_t rd; - rd = fpStream->Read(fpBuffer, fnBufferSize); - if (rd >= 0) { - fnLen = rd; - fnPos = 0; - } - return rd; + ssize_t len = fStream->Read(fBuffer, fBufferSize); + if (len < 0) + return len; + fLen = len; + fPos = 0; + return fLen; } Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-22 18:39:39 UTC (rev 24067) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-22 21:21:39 UTC (rev 24068) @@ -1,34 +1,11 @@ -/*****************************************************************************/ -// StreamBuffer -// Written by Michael Wilber, Haiku Translation Kit Team -// -// StreamBuffer.h -// -// This class is for buffering data from a BPositionIO object in order to -// improve performance for cases when small amounts of data are frequently -// read from a BPositionIO object. -// -// -// Copyright (c) 2003 Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2008, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors : + * Michael Wilber + * J?r?me Duval + */ #ifndef STREAM_BUFFER_H #define STREAM_BUFFER_H @@ -39,32 +16,37 @@ class StreamBuffer { public: - StreamBuffer(BPositionIO *pstream, size_t nbuffersize, bool binitialread); + StreamBuffer(BPositionIO *stream, size_t bufferSize, bool toRead = true); ~StreamBuffer(); status_t InitCheck(); // Determines whether the constructor failed or not - ssize_t Read(uint8 *pinto, size_t nbytes); + ssize_t Read(void *buffer, size_t size); // copy nbytes from the stream into pinto + void Write(void *buffer, size_t size); + // copy nbytes from the stream into pinto + bool Seek(off_t position); // seek the stream to the given position private: - ssize_t ReadStream(); + ssize_t _ReadStream(); // Load the stream buffer from the stream - BPositionIO *fpStream; + BPositionIO *fStream; // stream object this object is buffering - uint8 *fpBuffer; + uint8 *fBuffer; // buffered data from fpStream - size_t fnBufferSize; + size_t fBufferSize; // number of bytes of memory allocated for fpBuffer - size_t fnLen; + size_t fLen; // number of bytes of actual data in fpBuffer - size_t fnPos; + size_t fPos; // current position in the buffer + bool fToRead; + // whether the stream is to be read. }; #endif Modified: haiku/trunk/src/add-ons/translators/tga/TGATranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/tga/TGATranslator.cpp 2008-02-22 18:39:39 UTC (rev 24067) +++ haiku/trunk/src/add-ons/translators/tga/TGATranslator.cpp 2008-02-22 21:21:39 UTC (rev 24068) @@ -1640,7 +1640,7 @@ memset(bitsRowData, 0xff, bitsRowBytes); uint8 *pbitspixel = bitsRowData; uint8 packethead; - StreamBuffer sbuf(inSource, TGA_STREAM_BUFFER_SIZE, true); + StreamBuffer sbuf(inSource, TGA_STREAM_BUFFER_SIZE); ssize_t rd = 0; if (sbuf.InitCheck() == B_OK) rd = sbuf.Read(&packethead, 1); @@ -1945,7 +1945,7 @@ memset(bitsRowData, 0xff, bitsRowBytes); uint8 *pbitspixel = bitsRowData; uint8 packethead; - StreamBuffer sbuf(inSource, TGA_STREAM_BUFFER_SIZE, true); + StreamBuffer sbuf(inSource, TGA_STREAM_BUFFER_SIZE); ssize_t rd = 0; if (sbuf.InitCheck() == B_OK) rd = sbuf.Read(&packethead, 1); From korli at mail.berlios.de Fri Feb 22 23:00:42 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 22 Feb 2008 23:00:42 +0100 Subject: [Haiku-commits] r24069 - in haiku/trunk/src/add-ons/translators: exr shared Message-ID: <200802222200.m1MM0gUU013688@sheep.berlios.de> Author: korli Date: 2008-02-22 23:00:41 +0100 (Fri, 22 Feb 2008) New Revision: 24069 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24069&view=rev Modified: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h Log: EXRTranslator now uses the StreamBuffer class added StreamBuffer::Position() Modified: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-22 21:21:39 UTC (rev 24068) +++ haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-22 22:00:41 UTC (rev 24069) @@ -8,7 +8,7 @@ IStreamWrapper::IStreamWrapper(const char *filename, BPositionIO *stream) : IStream(filename), - fStream(stream) + fStream(stream, 2048) { } @@ -21,7 +21,7 @@ bool IStreamWrapper::read(char c[/*n*/], int n) { - int actual = fStream->Read(c, n); + int actual = fStream.Read(c, n); if (actual < B_OK) { } @@ -32,12 +32,12 @@ Int64 IStreamWrapper::tellg() { - return fStream->Position(); + return fStream.Position(); } void IStreamWrapper::seekg(Int64 pos) { - fStream->Seek(pos, SEEK_SET); + fStream.Seek(pos); } Modified: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h =================================================================== --- haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h 2008-02-22 21:21:39 UTC (rev 24068) +++ haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.h 2008-02-22 22:00:41 UTC (rev 24069) @@ -8,6 +8,8 @@ #include #include +#include "StreamBuffer.h" + using namespace Imf; class IStreamWrapper : public IStream { @@ -20,7 +22,7 @@ virtual void seekg(Int64 pos); private: - BPositionIO *fStream; + StreamBuffer fStream; }; #endif /* ISTREAM_WRAPPER_H */ Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-22 21:21:39 UTC (rev 24068) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-22 22:00:41 UTC (rev 24069) @@ -202,7 +202,34 @@ return false; } + // --------------------------------------------------------------- +// Position +// +// Returns the current position in the stream. +// +// Preconditions: fBuffer must be allocated and fBufferSize +// must be valid +// +// Parameters: +// +// Postconditions: +// +// Returns: the position +// --------------------------------------------------------------- +off_t +StreamBuffer::Position() +{ + off_t position = fStream->Position(); + if (fToRead) + position -= fPos; + else + position += fLen; + return position; +} + + +// --------------------------------------------------------------- // _ReadStream // // Fills the stream buffer with data read in from the stream Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-22 21:21:39 UTC (rev 24068) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-22 22:00:41 UTC (rev 24069) @@ -31,6 +31,8 @@ bool Seek(off_t position); // seek the stream to the given position + off_t Position(); + // return the actual position private: ssize_t _ReadStream(); // Load the stream buffer from the stream From jackburton at mail.berlios.de Fri Feb 22 23:30:42 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 22 Feb 2008 23:30:42 +0100 Subject: [Haiku-commits] r24070 - haiku/trunk/src/tests/kits/interface Message-ID: <200802222230.m1MMUgG0016193@sheep.berlios.de> Author: jackburton Date: 2008-02-22 23:30:34 +0100 (Fri, 22 Feb 2008) New Revision: 24070 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24070&view=rev Added: haiku/trunk/src/tests/kits/interface/WidthBufferTest.cpp Removed: haiku/trunk/src/tests/kits/interface/bwidthbuffer/ Modified: haiku/trunk/src/tests/kits/interface/Jamfile Log: Refactored BWidthBuffer test into something more useful. Looks like the class has some problems (hangs while calculating width of lines inside termcap, cf bug #1690 Modified: haiku/trunk/src/tests/kits/interface/Jamfile =================================================================== --- haiku/trunk/src/tests/kits/interface/Jamfile 2008-02-22 22:00:41 UTC (rev 24069) +++ haiku/trunk/src/tests/kits/interface/Jamfile 2008-02-22 22:30:34 UTC (rev 24070) @@ -11,7 +11,6 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) bdeskbar ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) bpolygon ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) bregion ] ; -SEARCH_SOURCE += [ FDirName $(SUBDIR) bwidthbuffer ] ; SEARCH_SOURCE += [ FDirName $(TOP) src kits interface ] ; @@ -48,11 +47,7 @@ RegionInclude.cpp RegionIntersect.cpp RegionOffsetBy.cpp - - #_BWidthBuffer_ - WidthBufferTest.cpp - WidthBufferSimpleTest.cpp - + : be $(TARGET_LIBSTDC++) ; @@ -128,6 +123,12 @@ : be ; + +SimpleTest WidthBufferTest : + WidthBufferTest.cpp + : be +; + SEARCH on [ FGristFiles ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp Slider.cpp Control.cpp ] = [ FDirName $(HAIKU_TOP) src kits interface ] ; Added: haiku/trunk/src/tests/kits/interface/WidthBufferTest.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/WidthBufferTest.cpp 2008-02-22 22:00:41 UTC (rev 24069) +++ haiku/trunk/src/tests/kits/interface/WidthBufferTest.cpp 2008-02-22 22:30:34 UTC (rev 24070) @@ -0,0 +1,89 @@ +/* +** Copyright 2008, Stefano Ceccherini (stefano.ceccherini at gmail.com). +** All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + +#include +#include + +#include +#include + +#include + + +class App : public BApplication { +public: + App(); + ~App(); + virtual void ReadyToRun(); + +private: + _BWidthBuffer_ *fWidthBuffer; + thread_id fThread; + + int32 TesterFunc(); + static int32 _thread(void *data); + +}; + + +int main() +{ + App app; + app.Run(); + return 0; +} + + +App::App() + :BApplication("application/x-vnd-WidthBufferTest") +{ + fWidthBuffer = new _BWidthBuffer_; + fThread = spawn_thread(App::_thread, "widthbuffer tester", + B_NORMAL_PRIORITY, this); +} + + +void +App::ReadyToRun() +{ + resume_thread(fThread); +} + + +App::~App() +{ + status_t status; + wait_for_thread(fThread, &status); + delete fWidthBuffer; +} + + +int32 +App::TesterFunc() +{ + FILE *file = fopen("/boot/beos/etc/termcap", "r"); + if (file != NULL) { + char buffer[512]; + while (fgets(buffer, 512, file)) { + float width = fWidthBuffer->StringWidth(buffer, 0, + strlen(buffer), be_plain_font); + printf("string: %s, width: %f\n", buffer, width); + } + fclose(file); + } + + PostMessage(B_QUIT_REQUESTED); + + return 0; +} + + +int32 +App::_thread(void *data) +{ + return static_cast(data)->TesterFunc(); +} + From jackburton at mail.berlios.de Sat Feb 23 01:46:51 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 23 Feb 2008 01:46:51 +0100 Subject: [Haiku-commits] r24071 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802230046.m1N0kpXt014510@sheep.berlios.de> Author: jackburton Date: 2008-02-23 01:46:50 +0100 (Sat, 23 Feb 2008) New Revision: 24071 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24071&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: such a long debugging session for such a silly error: the new hashed_escapements struct was never put into the width table when we grew the hash. The BWidthBufferTest now works. Simplified a bit the code. Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-22 22:30:34 UTC (rev 24070) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-23 00:46:50 UTC (rev 24071) @@ -1,9 +1,9 @@ /* - * Copyright 2003-2006, Haiku, Inc. + * Copyright 2003-2008, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: - * Stefano Ceccherini (burton666 at libero.it) + * Stefano Ceccherini (stefano.ceccherini at gmail.com) */ //! Caches string widths in a hash table, to avoid a trip to the app server. @@ -83,7 +83,7 @@ _BWidthBuffer_::StringWidth(const char *inText, int32 fromOffset, int32 length, const BFont *inStyle) { - if (inText == NULL) + if (inText == NULL || length == 0) return 0; int32 index = 0; @@ -94,36 +94,35 @@ int32 numChars = 0; int32 textLen = 0; + char *sourceText = (char *)inText + fromOffset; const float fontSize = inStyle->Size(); float stringWidth = 0; - if (length > 0) { - for (int32 charLen = 0, currentOffset = fromOffset; - currentOffset < fromOffset + length; - currentOffset += charLen) { - charLen = UTF8NextCharLen(inText + currentOffset); + for (int32 charLen = 0; + sourceText < inText + length; + sourceText += charLen) { + charLen = UTF8NextCharLen(sourceText); - // End of string, bail out - if (charLen == 0) - break; + // End of string, bail out + if (charLen <= 0) + break; - // Some magic, to uniquely identify this charachter - const uint32 value = CharToCode(inText + currentOffset, charLen); + // Some magic, to uniquely identify this charachter + const uint32 value = CharToCode(sourceText, charLen); - float escapement; - if (GetEscapement(value, index, &escapement)) { - // Well, we've got a match for this charachter - stringWidth += escapement; - } else { - // Store this charachter into an array, which we'll - // pass to HashEscapements() later - int32 offset = textLen; - textLen += charLen; - numChars++; - text = (char *)realloc(text, textLen); - for (int32 x = 0; x < charLen; x++) - text[offset + x] = inText[currentOffset + x]; - } - } + float escapement; + if (GetEscapement(value, index, &escapement)) { + // Well, we've got a match for this charachter + stringWidth += escapement; + } else { + // Store this charachter into an array, which we'll + // pass to HashEscapements() later + int32 offset = textLen; + textLen += charLen; + numChars++; + text = (char *)realloc(text, textLen); + for (int32 x = 0; x < charLen; x++) + text[offset + x] = sourceText[x]; + } } if (text != NULL) { @@ -232,7 +231,6 @@ const hashed_escapement *widths = static_cast(table.widths); uint32 hashed = Hash(value) & (table.tableCount - 1); - DEBUG_ONLY(uint32 iterations = 1;) uint32 found; while ((found = widths[hashed].code) != kInvalidCode) { if (found == value) @@ -240,14 +238,11 @@ if (++hashed >= (uint32)table.tableCount) hashed = 0; - DEBUG_ONLY(iterations++;) } if (found == kInvalidCode) return false; - //PRINT(("Value found with %d iterations\n", iterations)); - if (escapement != NULL) *escapement = widths[hashed].escapement; @@ -283,76 +278,81 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLen, int32 tableIndex, const BFont *inStyle) { + ASSERT(inText != NULL); + ASSERT(numChars > 0); + ASSERT(textLen > 0); + float *escapements = new float[numChars]; inStyle->GetEscapements(inText, numChars, escapements); _width_table_ &table = fBuffer[tableIndex]; hashed_escapement *widths = static_cast(table.widths); - int32 offset = 0; int32 charCount = 0; - + char *text = (char *)inText; + const char *textEnd = inText + textLen; // Insert the escapements into the hash table do { - const int32 charLen = UTF8NextCharLen(inText + offset); + const int32 charLen = UTF8NextCharLen(text); if (charLen == 0) break; - const uint32 value = CharToCode(inText + offset, charLen); - + const uint32 value = CharToCode(text, charLen); + uint32 hashed = Hash(value) & (table.tableCount - 1); uint32 found = widths[hashed].code; - // Check if the value is already in the table - if (found != value) { - while ((found = widths[hashed].code) != kInvalidCode) { - if (found == value) - break; - if (++hashed >= (uint32)table.tableCount) - hashed = 0; - } + if (found == value) { + text += charLen; + continue; + } + + while ((found = widths[hashed].code) != kInvalidCode) { + if (found == value) + break; + if (++hashed >= (uint32)table.tableCount) + hashed = 0; + } - if (found == kInvalidCode) { - // The value is not in the table. Add it. - widths[hashed].code = value; - widths[hashed].escapement = escapements[charCount]; - table.hashCount++; + if (found == kInvalidCode) { + // The value is not in the table. Add it. + widths[hashed].code = value; + widths[hashed].escapement = escapements[charCount]; + table.hashCount++; - // We always keep some free space in the hash table - // TODO: Not sure how much space, currently we double - // the current size when hashCount is at least 2/3 of - // the total size. - if (table.tableCount * 2 / 3 <= table.hashCount) { - table.hashCount = 0; - const int32 newSize = table.tableCount * 2; - - // Create and initialize a new hash table - hashed_escapement *newWidths = new hashed_escapement[newSize]; - - // Rehash the values, and put them into the new table - for (int32 oldPos = 0; oldPos < table.tableCount; oldPos++) { - if (widths[oldPos].code != kInvalidCode) { - uint32 newPos = Hash(widths[oldPos].code) & (newSize - 1); - while (newWidths[newPos].code != kInvalidCode) { - if (++newPos >= (uint32)newSize) - newPos = 0; - } - newWidths[newPos].code = widths[oldPos].code; - newWidths[newPos].escapement = widths[oldPos].escapement; - table.hashCount++; + // We always keep some free space in the hash table: + // we double the current size when hashCount is 2/3 of + // the total size. + if (table.tableCount * 2 / 3 <= table.hashCount) { + const int32 newSize = table.tableCount * 2; + + // Create and initialize a new hash table + hashed_escapement *newWidths = new hashed_escapement[newSize]; + for (int32 i = 0; i < newSize; i++) + newWidths[i].code = kInvalidCode; + + // Rehash the values, and put them into the new table + for (uint32 oldPos = 0; oldPos < (uint32)table.tableCount; oldPos++) { + if (widths[oldPos].code != kInvalidCode) { + uint32 newPos = Hash(widths[oldPos].code) & (newSize - 1); + while (newWidths[newPos].code != kInvalidCode) { + if (++newPos >= (uint32)newSize) + newPos = 0; } + newWidths[newPos] = widths[oldPos]; + } - table.tableCount = newSize; + } + table.tableCount = newSize; - // Delete the old table, and put the new pointer into the _width_table_ - delete[] widths; - widths = newWidths; - } + // Delete the old table, and put the new pointer into the _width_table_ + delete[] widths; + table.widths = widths = newWidths; } } charCount++; - offset += charLen; - } while (offset < textLen); + text += charLen; + } while (text < textEnd); // Calculate the width of the string float width = 0; From jackburton at mail.berlios.de Sat Feb 23 01:49:18 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 23 Feb 2008 01:49:18 +0100 Subject: [Haiku-commits] r24072 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802230049.m1N0nIPS014742@sheep.berlios.de> Author: jackburton Date: 2008-02-23 01:49:17 +0100 (Sat, 23 Feb 2008) New Revision: 24072 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24072&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: removed debug leftover Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-23 00:46:50 UTC (rev 24071) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-23 00:49:17 UTC (rev 24072) @@ -328,8 +328,6 @@ // Create and initialize a new hash table hashed_escapement *newWidths = new hashed_escapement[newSize]; - for (int32 i = 0; i < newSize; i++) - newWidths[i].code = kInvalidCode; // Rehash the values, and put them into the new table for (uint32 oldPos = 0; oldPos < (uint32)table.tableCount; oldPos++) { From fekdahl at gmail.com Sat Feb 23 08:40:55 2008 From: fekdahl at gmail.com (Fredrik Ekdahl) Date: Sat, 23 Feb 2008 08:40:55 +0100 Subject: [Haiku-commits] r24068 - in haiku/trunk/src/add-ons/translators: pcx shared tga In-Reply-To: <200802222121.m1MLLduL010018@sheep.berlios.de> References: <200802222121.m1MLLduL010018@sheep.berlios.de> Message-ID: <1203752455.6994.1.camel@ekdahl> fre 2008-02-22 klockan 22:21 +0100 skrev korli at BerliOS: > Author: korli > Date: 2008-02-22 22:21:39 +0100 (Fri, 22 Feb 2008) > New Revision: 24068 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24068&view=rev > > Modified: > haiku/trunk/src/add-ons/translators/pcx/PCX.cpp > haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp > haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h > haiku/trunk/src/add-ons/translators/tga/TGATranslator.cpp > Log: > PCXTranslator now uses the StreamBuffer class > fixed StreamBuffer::Read() to handle bigger reads > added a write mode > revised code style and license header > And here comes a build fix for gcc 4. -------------- next part -------------- A non-text attachment was scrubbed... Name: StreamBuffer.diff Type: text/x-patch Size: 852 bytes Desc: not available URL: From stippi at mail.berlios.de Sat Feb 23 11:00:53 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 23 Feb 2008 11:00:53 +0100 Subject: [Haiku-commits] r24073 - haiku/trunk/src/tools/vmdkheader Message-ID: <200802231000.m1NA0rVP002614@sheep.berlios.de> Author: stippi Date: 2008-02-23 11:00:52 +0100 (Sat, 23 Feb 2008) New Revision: 24073 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24073&view=rev Modified: haiku/trunk/src/tools/vmdkheader/vmdkheader.cpp Log: * Fixed warnings. * Truncated lines to 80 char width. Modified: haiku/trunk/src/tools/vmdkheader/vmdkheader.cpp =================================================================== --- haiku/trunk/src/tools/vmdkheader/vmdkheader.cpp 2008-02-23 00:49:17 UTC (rev 24072) +++ haiku/trunk/src/tools/vmdkheader/vmdkheader.cpp 2008-02-23 10:00:52 UTC (rev 24073) @@ -38,7 +38,8 @@ const char *file = NULL; if (sizeof(SparseExtentHeader) != 512) { - fprintf(stderr, "compilation error: struct size is %u byte\n", sizeof(SparseExtentHeader)); + fprintf(stderr, "compilation error: struct size is %lu byte\n", + sizeof(SparseExtentHeader)); exit(EXIT_FAILURE); } @@ -97,7 +98,8 @@ SparseExtentHeader header; if (headersize < sizeof(desc) + sizeof(header)) { - fprintf(stderr, "Error: header size must be at least %u byte\n", sizeof(desc) + sizeof(header)); + fprintf(stderr, "Error: header size must be at least %lu byte\n", + sizeof(desc) + sizeof(header)); exit(EXIT_FAILURE); } @@ -185,7 +187,8 @@ int fd = open(file, O_RDWR | O_CREAT, 0666); if (fd < 0) { - fprintf(stderr, "Error: couldn't open file %s (%s)\n", file, strerror(errno)); + fprintf(stderr, "Error: couldn't open file %s (%s)\n", file, + strerror(errno)); exit(EXIT_FAILURE); } if (sizeof(header) != write(fd, &header, sizeof(header))) @@ -205,7 +208,8 @@ return 0; write_err: - fprintf(stderr, "Error: writing file %s failed (%s)\n", file, strerror(errno)); + fprintf(stderr, "Error: writing file %s failed (%s)\n", file, + strerror(errno)); close(fd); exit(EXIT_FAILURE); } From stippi at mail.berlios.de Sat Feb 23 12:03:38 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 23 Feb 2008 12:03:38 +0100 Subject: [Haiku-commits] r24074 - haiku/trunk/src/add-ons/translators/shared Message-ID: <200802231103.m1NB3cGa007871@sheep.berlios.de> Author: stippi Date: 2008-02-23 12:03:37 +0100 (Sat, 23 Feb 2008) New Revision: 24074 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24074&view=rev Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp Log: * Got rid of the casting in Read, motivated by a patch sent by Fredrik Ekdahl, should also fix GCC4 build. Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-23 10:00:52 UTC (rev 24073) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-23 11:03:37 UTC (rev 24074) @@ -8,6 +8,7 @@ */ #include +#include #include "StreamBuffer.h" #ifndef min @@ -115,17 +116,20 @@ // error code returned by BPositionIO::Read() // --------------------------------------------------------------- ssize_t -StreamBuffer::Read(void *pinto, size_t nbytes) +StreamBuffer::Read(void *_pinto, size_t nbytes) { + if (_pinto == NULL) + return B_BAD_VALUE; if (nbytes == 0) return 0; - + ssize_t result = B_ERROR; + uint8 *pinto = (uint8 *)_pinto; size_t totalRead = min(nbytes, fLen - fPos); memcpy(pinto, fBuffer + fPos, totalRead); fPos += totalRead; - (uint8 *)pinto += totalRead; + pinto += totalRead; nbytes -= totalRead; while (nbytes > 0) { @@ -136,7 +140,7 @@ size_t left = min(nbytes, fLen - fPos); memcpy(pinto, fBuffer + fPos, left); fPos += left; - (uint8 *)pinto += left; + pinto += left; nbytes -= left; totalRead += left; } From stippi at mail.berlios.de Sat Feb 23 12:52:55 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 23 Feb 2008 12:52:55 +0100 Subject: [Haiku-commits] r24075 - haiku/trunk/src/kits/interface Message-ID: <200802231152.m1NBqtda016591@sheep.berlios.de> Author: stippi Date: 2008-02-23 12:52:53 +0100 (Sat, 23 Feb 2008) New Revision: 24075 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24075&view=rev Modified: haiku/trunk/src/kits/interface/CheckBox.cpp Log: * Prevent cross from being too close to the surroundings. * No need for B_OP_OVER anymore since ages. Modified: haiku/trunk/src/kits/interface/CheckBox.cpp =================================================================== --- haiku/trunk/src/kits/interface/CheckBox.cpp 2008-02-23 11:03:37 UTC (rev 24074) +++ haiku/trunk/src/kits/interface/CheckBox.cpp 2008-02-23 11:52:53 UTC (rev 24075) @@ -154,18 +154,15 @@ // Checkmark if (Value() == B_CONTROL_ON) { - rect.InsetBy(2, 2); + rect.InsetBy(3, 3); SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); SetPenSize(2); - SetDrawingMode(B_OP_OVER); - // needed because of anti-aliasing StrokeLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.bottom)); StrokeLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.top)); SetPenSize(1); - SetDrawingMode(B_OP_COPY); } // Label @@ -207,19 +204,16 @@ // Checkmark if (Value() == B_CONTROL_ON) { - rect.InsetBy(2, 2); + rect.InsetBy(3, 3); SetHighColor(tint_color(ui_color(B_KEYBOARD_NAVIGATION_COLOR), B_DISABLED_MARK_TINT)); SetPenSize(2); - SetDrawingMode(B_OP_OVER); - // needed because of anti-aliasing StrokeLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.bottom)); StrokeLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.top)); SetPenSize(1); - SetDrawingMode(B_OP_COPY); } // Label From stippi at mail.berlios.de Sat Feb 23 12:54:34 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 23 Feb 2008 12:54:34 +0100 Subject: [Haiku-commits] r24076 - haiku/trunk/src/kits/interface Message-ID: <200802231154.m1NBsYb7018060@sheep.berlios.de> Author: stippi Date: 2008-02-23 12:54:34 +0100 (Sat, 23 Feb 2008) New Revision: 24076 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24076&view=rev Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp Log: * Removed #ifdefs around cursor code (ie activate it). * Replaced non-stylish/conform looking cursor shapes with cool looking cursor shapes. (I am always delighted by WonderBrush's cursor code output...) Modified: haiku/trunk/src/kits/interface/ColumnListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-23 11:52:53 UTC (rev 24075) +++ haiku/trunk/src/kits/interface/ColumnListView.cpp 2008-02-23 11:54:34 UTC (rev 24076) @@ -50,9 +50,7 @@ #include #include -#if _INCLUDES_CLASS_CURSOR #include -#endif #include #include #include @@ -80,34 +78,54 @@ static const unsigned char kResizeCursorData[] = { 16, 1, 8, 8, - 0, 0, 1, 0x80, 1, 0x80, 1, 0x80, 9, 0x90, 0x19, 0x98, 0x39, 0x09c, 0x79, 0x9e, - 0x79, 0x9e, 0x39, 0x9c, 0x19, 0x98, 0x9, 0x90, 1, 0x80, 1, 0x80, 1, 0x80, 0, 0, - 3, 0xc0, 3, 0xc0, 3, 0xc0, 0xf, 0xf0, 0x1f, 0xf8, 0x3f, 0xfa, 0x7f, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0xfe, 0x3f, 0xfa, 0x1f, 0xf8, 0xf, 0xf0, 3, 0xc0, 3, 0xc0, 3, 0xc0 + 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, + 0x1a, 0x58, 0x2a, 0x54, 0x4a, 0x52, 0x8a, 0x51, + 0x8a, 0x51, 0x4a, 0x52, 0x2a, 0x54, 0x1a, 0x58, + 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, + + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, + 0x1b, 0xd8, 0x3b, 0xdc, 0x7b, 0xde, 0xfb, 0xdf, + 0xfb, 0xdf, 0x7b, 0xde, 0x3b, 0xdc, 0x1b, 0xd8, + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 }; static const unsigned char kMaxResizeCursorData[] = { 16, 1, 8, 8, - 0, 0, 1, 0x80, 1, 0x80, 1, 0x80, 9, 0x80, 0x19, 0x80, 0x39, 0x80, 0x79, 0x80, - 0x79, 0x80, 0x39, 0x80, 0x19, 0x80, 0x9, 0x80, 1, 0x80, 1, 0x80, 1, 0x80, 0, 0, - 3, 0xc0, 3, 0xc0, 3, 0xc0, 0xf, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, 0x7f, 0xc0, 0xff, 0xc0, - 0xff, 0xc0, 0x7f, 0xc0, 0x3f, 0xc0, 0x1f, 0xc0, 0xf, 0xc0, 3, 0xc0, 3, 0xc0, 3, 0xc0 + 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, + 0x1a, 0x40, 0x2a, 0x40, 0x4a, 0x40, 0x8a, 0x40, + 0x8a, 0x40, 0x4a, 0x40, 0x2a, 0x40, 0x1a, 0x40, + 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, + + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, + 0x1b, 0xc0, 0x3b, 0xc0, 0x7b, 0xc0, 0xfb, 0xc0, + 0xfb, 0xc0, 0x7b, 0xc0, 0x3b, 0xc0, 0x1b, 0xc0, + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 }; static const unsigned char kMinResizeCursorData[] = { 16, 1, 8, 8, - 0, 0, 1, 0x80, 1, 0x80, 1, 0x80, 1, 0x90, 1, 0x98, 1, 0x09c, 1, 0x9e, - 1, 0x9e, 1, 0x9c, 1, 0x98, 1, 0x90, 1, 0x80, 1, 0x80, 1, 0x80, 0, 0, - 3, 0xc0, 3, 0xc0, 3, 0xc0, 3, 0xf0, 3, 0xf8, 3, 0xfa, 3, 0xfe, 3, 0xff, - 3, 0xff, 3, 0xfe, 3, 0xfa, 3, 0xf8, 3, 0xf0, 3, 0xc0, 3, 0xc0, 3, 0xc0 + 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, + 0x02, 0x58, 0x02, 0x54, 0x02, 0x52, 0x02, 0x51, + 0x02, 0x51, 0x02, 0x52, 0x02, 0x54, 0x02, 0x58, + 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, + + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, + 0x03, 0xd8, 0x03, 0xdc, 0x03, 0xde, 0x03, 0xdf, + 0x03, 0xdf, 0x03, 0xde, 0x03, 0xdc, 0x03, 0xd8, + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 }; static const unsigned char kColumnMoveCursorData[] = { 16, 1, 8, 8, - 1, 0x80, 3, 0xc0, 7, 0xe0, 0, 0, 0, 0, 0x20, 4, 0x61, 0x86, 0xe3, 0xc7, - 0xe3, 0xc7, 0x61, 0x86, 0x20, 4, 0, 0, 0, 0, 7, 0xe0, 3, 0xc0, 1, 0x80, - 1, 0x80, 3, 0xc0, 7, 0xe0, 0, 0, 0, 0, 0x20, 4, 0x61, 0x86, 0xe3, 0xc7, - 0xe3, 0xc7, 0x61, 0x86, 0x20, 4, 0, 0, 0, 0, 7, 0xe0, 3, 0xc0, 1, 0x80 + 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, + 0x1e, 0x78, 0x2a, 0x54, 0x4e, 0x72, 0x80, 0x01, + 0x80, 0x01, 0x4e, 0x72, 0x2a, 0x54, 0x1e, 0x78, + 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, + + 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, + 0x1f, 0xf8, 0x3b, 0xdc, 0x7f, 0xfe, 0xff, 0xff, + 0xff, 0xff, 0x7f, 0xfe, 0x3b, 0xdc, 0x1f, 0xf8, + 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80 }; static const unsigned char kUpSortArrow8x8[] = { @@ -259,14 +277,12 @@ BBitmap *fUpSortArrow; BBitmap *fDownSortArrow; -#if _INCLUDES_CLASS_CURSOR + BCursor *fResizeCursor; BCursor *fMinResizeCursor; BCursor *fMaxResizeCursor; BCursor *fColumnMoveCursor; -#endif - typedef BView _inherited; }; @@ -1610,12 +1626,11 @@ fUpSortArrow->SetBits((const void*) kUpSortArrow8x8, 64, 0, B_CMAP8); fDownSortArrow->SetBits((const void*) kDownSortArrow8x8, 64, 0, B_CMAP8); -#if _INCLUDES_CLASS_CURSOR fResizeCursor = new BCursor(kResizeCursorData); fMinResizeCursor = new BCursor(kMinResizeCursorData); fMaxResizeCursor = new BCursor(kMaxResizeCursorData); fColumnMoveCursor = new BCursor(kColumnMoveCursorData); -#endif + FixScrollBar(true); } @@ -1632,12 +1647,10 @@ delete fUpSortArrow; delete fDownSortArrow; -#if _INCLUDES_CLASS_CURSOR delete fResizeCursor; delete fMaxResizeCursor; delete fMinResizeCursor; delete fColumnMoveCursor; -#endif } void TitleView::ColumnAdded(BColumn *column) @@ -1839,14 +1852,12 @@ fColumnsWidth += dX; // Update the cursor -#if _INCLUDES_CLASS_CURSOR if (fSelectedColumn->Width() == minWidth) - SetViewCursor(fMinResizeCursor, false); + SetViewCursor(fMinResizeCursor, true); else if (fSelectedColumn->Width() == maxWidth) - SetViewCursor(fMaxResizeCursor, false); + SetViewCursor(fMaxResizeCursor, true); else - SetViewCursor(fResizeCursor, false); -#endif + SetViewCursor(fResizeCursor, true); } } @@ -2177,9 +2188,7 @@ if(fColumnFlags & B_ALLOW_COLUMN_MOVE) { fCurrentState = DRAG_COLUMN_INSIDE_TITLE; ComputeDragBoundries(fSelectedColumn, position); -#if _INCLUDES_CLASS_CURSOR - SetViewCursor(fColumnMoveCursor, false); -#endif + SetViewCursor(fColumnMoveCursor, true); #if DRAG_TITLE_OUTLINE BRect invalidRect(fSelectedColumnRect); invalidRect.OffsetTo(position.x - fClickPoint.x, 0); @@ -2281,17 +2290,15 @@ } // Update the cursor -#if _INCLUDES_CLASS_CURSOR if (resizeColumn) { if (resizeColumn->Width() == resizeColumn->MinWidth()) - SetViewCursor(fMinResizeCursor, false); + SetViewCursor(fMinResizeCursor, true); else if (resizeColumn->Width() == resizeColumn->MaxWidth()) - SetViewCursor(fMaxResizeCursor, false); + SetViewCursor(fMaxResizeCursor, true); else - SetViewCursor(fResizeCursor, false); + SetViewCursor(fResizeCursor, true); } else - SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, false); -#endif + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, true); break; } } @@ -2306,9 +2313,7 @@ ResizeSelectedColumn(position); fCurrentState = INACTIVE; FixScrollBar(false); -#if _INCLUDES_CLASS_CURSOR - SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, false); -#endif + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, true); break; case PRESSING_COLUMN: { @@ -2344,17 +2349,13 @@ #else Invalidate(fSelectedColumnRect); #endif -#if _INCLUDES_CLASS_CURSOR - SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, false); -#endif + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, true); break; case DRAG_COLUMN_OUTSIDE_TITLE: fCurrentState = INACTIVE; EndRectTracking(); -#if _INCLUDES_CLASS_CURSOR - SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, false); -#endif + SetViewCursor(B_CURSOR_SYSTEM_DEFAULT, true); break; default: @@ -3684,6 +3685,7 @@ void OutlineView::ScrollTo(BPoint position) { +printf("OutlineView::ScrollTo(BPoint(%.1f, %.1f))\n", position.x, position.y); fVisibleRect.OffsetTo(position.x, position.y); // In FixScrollBar, we might not have been able to change the size of @@ -3697,6 +3699,7 @@ FixScrollBar(true); _inherited::ScrollTo(position); +printf(" scrolled to BPoint(%.1f, %.1f)\n", Bounds().left, Bounds().top); } const BRect& OutlineView::VisibleRect() const From korli at users.berlios.de Sat Feb 23 13:19:11 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 23 Feb 2008 13:19:11 +0100 Subject: [Haiku-commits] r24074 - haiku/trunk/src/add-ons/translators/shared In-Reply-To: <200802231103.m1NB3cGa007871@sheep.berlios.de> References: <200802231103.m1NB3cGa007871@sheep.berlios.de> Message-ID: 2008/2/23, stippi at BerliOS : > Author: stippi > Date: 2008-02-23 12:03:37 +0100 (Sat, 23 Feb 2008) > New Revision: 24074 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24074&view=rev > > Modified: > haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp > Log: > * Got rid of the casting in Read, motivated by a patch sent by Fredrik Ekdahl, > should also fix GCC4 build. > > Thanks Stephan! From superstippi at gmx.de Sat Feb 23 13:40:34 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 23 Feb 2008 13:40:34 +0100 Subject: [Haiku-commits] r24074 - haiku/trunk/src/add-ons/translators/shared In-Reply-To: References: <200802231103.m1NB3cGa007871@sheep.berlios.de> Message-ID: <20080223134034.43689.3@stippis2.1203763497.fake> On 2008-02-23 at 13:19:11 [+0100], J?r?me Duval wrote: > 2008/2/23, stippi at BerliOS : > > Author: stippi > > Date: 2008-02-23 12:03:37 +0100 (Sat, 23 Feb 2008) > > New Revision: 24074 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24074&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp > > Log: > > * Got rid of the casting in Read, motivated by a patch sent by Fredrik > > Ekdahl, > > should also fix GCC4 build. > > > > > > Thanks Stephan! De rien! Amiti?s, -Stephan From aldeck at mail.berlios.de Sat Feb 23 14:41:58 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Sat, 23 Feb 2008 14:41:58 +0100 Subject: [Haiku-commits] r24077 - haiku/trunk/src/apps/glteapot Message-ID: <200802231341.m1NDfwpL012419@sheep.berlios.de> Author: aldeck Date: 2008-02-23 14:41:57 +0100 (Sat, 23 Feb 2008) New Revision: 24077 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24077&view=rev Modified: haiku/trunk/src/apps/glteapot/ObjectView.cpp haiku/trunk/src/apps/glteapot/ObjectView.h haiku/trunk/src/apps/glteapot/TeapotWindow.cpp Log: - style cleanup - use "new style" casts - got rid of a goto Modified: haiku/trunk/src/apps/glteapot/ObjectView.cpp =================================================================== --- haiku/trunk/src/apps/glteapot/ObjectView.cpp 2008-02-23 11:54:34 UTC (rev 24076) +++ haiku/trunk/src/apps/glteapot/ObjectView.cpp 2008-02-23 13:41:57 UTC (rev 24077) @@ -22,17 +22,17 @@ float depthOfView = 30.0; float zRatio = 10.0; -float white[3] = {1.0,1.0,1.0}; -float dimWhite[3] = {0.25,0.25,0.25}; -float black[3] = {0.0,0.0,0.0}; -float foggy[3] = {0.4,0.4,0.4}; -float blue[3] = {0.0,0.0,1.0}; -float dimBlue[3] = {0.0,0.0,0.5}; -float yellow[3] = {1.0,1.0,0.0}; -float dimYellow[3] = {0.5,0.5,0.0}; -float green[3] = {0.0,1.0,0.0}; -float dimGreen[3] = {0.0,0.5,0.0}; -float red[3] = {1.0,0.0,0.0}; +float white[3] = {1.0, 1.0, 1.0}; +float dimWhite[3] = {0.25, 0.25, 0.25}; +float black[3] = {0.0, 0.0, 0.0}; +float foggy[3] = {0.4, 0.4, 0.4}; +float blue[3] = {0.0, 0.0, 1.0}; +float dimBlue[3] = {0.0, 0.0, 0.5}; +float yellow[3] = {1.0, 1.0, 0.0}; +float dimYellow[3] = {0.5, 0.5, 0.0}; +float green[3] = {0.0, 1.0, 0.0}; +float dimGreen[3] = {0.0, 0.5, 0.0}; +float red[3] = {1.0, 0.0, 0.0}; float* bgColor = black; @@ -96,26 +96,26 @@ static int32 simonThread(void* cookie) { - ObjectView* ov = (ObjectView*)cookie; + ObjectView* objectView = reinterpret_cast(cookie); int noPause = 0; - while (acquire_sem_etc(ov->quittingSem, 1, B_TIMEOUT, 0) == B_NO_ERROR) { - if (ov->SpinIt()) { - ov->DrawFrame(noPause); - release_sem(ov->quittingSem); + while (acquire_sem_etc(objectView->quittingSem, 1, B_TIMEOUT, 0) == B_NO_ERROR) { + if (objectView->SpinIt()) { + objectView->DrawFrame(noPause); + release_sem(objectView->quittingSem); noPause = 1; } else { - release_sem(ov->quittingSem); + release_sem(objectView->quittingSem); noPause = 0; - waitEvent(ov->drawEvent); + waitEvent(objectView->drawEvent); } } return 0; } -ObjectView::ObjectView(BRect r, char *name, ulong resizingMode, ulong options) - : BGLView(r,name,resizingMode,0,options), +ObjectView::ObjectView(BRect rect, char *name, ulong resizingMode, ulong options) + : BGLView(rect, name, resizingMode, 0, options), fHistEntries(0), fOldestEntry(0), fFps(true), @@ -147,9 +147,9 @@ fTrackingInfo.lastDx = 0.0f; fTrackingInfo.lastDy = 0.0f; - fLastObjectDistance = fObjectDistance = depthOfView/8; - quittingSem = create_sem(1,"quitting sem"); - drawEvent = create_sem(0,"draw event"); + fLastObjectDistance = fObjectDistance = depthOfView / 8; + quittingSem = create_sem(1, "quitting sem"); + drawEvent = create_sem(0, "draw event"); char findDir[PATH_MAX]; find_directory(B_BEOS_ETC_DIRECTORY, -1, true, findDir, PATH_MAX); @@ -173,12 +173,12 @@ float position[] = {0.0, 3.0, 3.0, 0.0}; float position1[] = {-3.0, -3.0, 3.0, 0.0}; float position2[] = {3.0, 0.0, 0.0, 0.0}; - float local_view[] = {0.0,0.0}; + float local_view[] = {0.0, 0.0}; // float ambient[] = {0.1745, 0.03175, 0.03175}; // float diffuse[] = {0.61424, 0.10136, 0.10136}; // float specular[] = {0.727811, 0.626959, 0.626959}; -// rgb_color black = {0,0,0,255}; - BRect r = Bounds(); +// rgb_color black = {0, 0, 0, 255}; + BRect bounds = Bounds(); BGLView::AttachedToWindow(); Window()->SetPulseRate(100000); @@ -193,8 +193,8 @@ glShadeModel(GL_SMOOTH); glLightfv(GL_LIGHT0, GL_POSITION, position); - glLightfv(GL_LIGHT0+1, GL_POSITION, position1); - glLightfv(GL_LIGHT0+2, GL_POSITION, position2); + glLightfv(GL_LIGHT0 + 1, GL_POSITION, position1); + glLightfv(GL_LIGHT0 + 2, GL_POSITION, position2); glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); glEnable(GL_LIGHT0); @@ -211,26 +211,25 @@ glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); - glMaterialf(GL_FRONT, GL_SHININESS, 0.6*128.0); + glMaterialf(GL_FRONT, GL_SHININESS, 0.6 * 128.0); - glClearColor(bgColor[0],bgColor[1],bgColor[2], 1.0); + glClearColor(bgColor[0], bgColor[1], bgColor[2], 1.0); glColor3f(1.0, 1.0, 1.0); - glViewport(0, 0, (GLint)r.IntegerWidth()+1, (GLint)r.IntegerHeight()+1); + glViewport(0, 0, (GLint)bounds.IntegerWidth() + 1, + (GLint)bounds.IntegerHeight() + 1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - float scale=displayScale; - // glOrtho (0.0, 16.0, 0, 16.0*(GLfloat)300/(GLfloat)300, - // -10.0, 10.0); - glOrtho(-scale, scale, -scale, scale, -scale*depthOfView, - scale*depthOfView); + + float scale = displayScale; + glOrtho(-scale, scale, -scale, scale, -scale * depthOfView, + scale * depthOfView); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); UnlockGL(); - fDrawThread = spawn_thread(simonThread, - "Simon", B_NORMAL_PRIORITY, this); + fDrawThread = spawn_thread(simonThread, "Simon", B_NORMAL_PRIORITY, this); resume_thread(fDrawThread); fForceRedraw = true; setEvent(drawEvent); @@ -264,12 +263,13 @@ ObjectView::Pulse() { Window()->Lock(); - BRect p = Parent()->Bounds(); - BRect b = Bounds(); - p.OffsetTo(0,0); - b.OffsetTo(0,0); - if (b != p) { - ResizeTo(p.right - p.left, p.bottom - p.top); + BRect parentBounds = Parent()->Bounds(); + BRect bounds = Bounds(); + parentBounds.OffsetTo(0, 0); + bounds.OffsetTo(0, 0); + if (bounds != parentBounds) { + ResizeTo(parentBounds.right - parentBounds.left, + parentBounds.bottom - parentBounds.top); } Window()->Unlock(); } @@ -278,98 +278,94 @@ void ObjectView::MessageReceived(BMessage* msg) { -// msg->PrintToStream(); - BMenuItem* i; - bool* b; + BMenuItem* item = NULL; + bool toggleItem = false; switch (msg->what) { - case bmsgFPS: + case kMsgFPS: fFps = (fFps) ? false : true; - msg->FindPointer("source", (void**)&i); - i->SetMarked(fFps); + msg->FindPointer("source", reinterpret_cast(&item)); + item->SetMarked(fFps); fForceRedraw = true; setEvent(drawEvent); break; - case bmsgAddModel: + case kMsgAddModel: fObjListLock.Lock(); fObjects.AddItem(new TriangleObject(this, teapotPath)); fObjListLock.Unlock(); setEvent(drawEvent); break; - case bmsgLights: + case kMsgLights: { - msg->FindPointer("source", (void**)&i); + msg->FindPointer("source", reinterpret_cast(&item)); long lightNum = msg->FindInt32("num"); long color = msg->FindInt32("color"); - BMenu *m = i->Menu(); - long index = m->IndexOf(i); - m->ItemAt(index)->SetMarked(true); - for (int i = 0; i < m->CountItems(); i++) { + BMenu *menu = item->Menu(); + long index = menu->IndexOf(item); + menu->ItemAt(index)->SetMarked(true); + for (int i = 0; i < menu->CountItems(); i++) { if (i != index) - m->ItemAt(i)->SetMarked(false); + menu->ItemAt(i)->SetMarked(false); } LockGL(); if (color != lightNone) { - glEnable(GL_LIGHT0+lightNum - 1); - glLightfv(GL_LIGHT0+lightNum - 1, GL_SPECULAR, + glEnable(GL_LIGHT0 + lightNum - 1); + glLightfv(GL_LIGHT0 + lightNum - 1, GL_SPECULAR, lights[color].specular); - glLightfv(GL_LIGHT0+lightNum - 1, GL_DIFFUSE, + glLightfv(GL_LIGHT0 + lightNum - 1, GL_DIFFUSE, lights[color].diffuse); - glLightfv(GL_LIGHT0+lightNum - 1, GL_AMBIENT, + glLightfv(GL_LIGHT0 + lightNum - 1, GL_AMBIENT, lights[color].ambient); } else { - glDisable(GL_LIGHT0+lightNum - 1); + glDisable(GL_LIGHT0 + lightNum - 1); } UnlockGL(); fForceRedraw = true; setEvent(drawEvent); break; } - case bmsgGouraud: - b = &fGouraud; - goto stateChange; - case bmsgZBuffer: - b = &fZbuf; - goto stateChange; - case bmsgCulling: - b = &fCulling; - goto stateChange; - case bmsgLighting: - b = &fLighting; - goto stateChange; - case bmsgFilled: - b = &fFilled; - goto stateChange; - case bmsgPerspective: - b = &fPersp; - goto stateChange; - case bmsgFog: - b = &fFog; - goto stateChange; - stateChange: - if (msg->FindPointer("source", (void**)&i) < B_OK) - i = NULL; - - if (!i) - return; - - if (*b) { - i->SetMarked(*b = false); - } else { - i->SetMarked(*b = true); - } - - setEvent(drawEvent); + case kMsgGouraud: + fGouraud = !fGouraud; + toggleItem = true; break; - default: - BGLView::MessageReceived(msg); + case kMsgZBuffer: + fZbuf = !fZbuf; + toggleItem = true; + break; + case kMsgCulling: + fCulling = !fCulling; + toggleItem = true; + break; + case kMsgLighting: + fLighting = !fLighting; + toggleItem = true; + break; + case kMsgFilled: + fFilled = !fFilled; + toggleItem = true; + break; + case kMsgPerspective: + fPersp = !fPersp; + toggleItem = true; + break; + case kMsgFog: + fFog = !fFog; + toggleItem = true; + break; } + + if (toggleItem && msg->FindPointer("source", reinterpret_cast(&item)) == B_OK){ + item->SetMarked(!item->IsMarked()); + setEvent(drawEvent); + } + + BGLView::MessageReceived(msg); } int -ObjectView::ObjectAtPoint(BPoint p) +ObjectView::ObjectAtPoint(const BPoint &point) { LockGL(); glShadeModel(GL_FLAT); @@ -378,16 +374,17 @@ glClearColor(black[0], black[1], black[2], 1.0); glClear(GL_COLOR_BUFFER_BIT | (fZbuf ? GL_DEPTH_BUFFER_BIT : 0)); - float f[3]; - f[1] = f[2] = 0; + float idColor[3]; + idColor[1] = idColor[2] = 0; for (int i = 0; i < fObjects.CountItems(); i++) { - // to take into account 16 bits colorspaces, only use the 5 highest bits of the red channel - f[0] = (255 - (i << 3)) / 255.0; - ((GLObject*)fObjects.ItemAt(i))->Draw(true, f); + // to take into account 16 bits colorspaces, + // only use the 5 highest bits of the red channel + idColor[0] = (255 - (i << 3)) / 255.0; + reinterpret_cast(fObjects.ItemAt(i))->Draw(true, idColor); } glReadBuffer(GL_BACK); uchar pixel[256]; - glReadPixels((GLint)p.x, (GLint)(Bounds().bottom - p.y), 1, 1, + glReadPixels((GLint)point.x, (GLint)(Bounds().bottom - point.y), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel); int objNum = pixel[0]; objNum = (255 - objNum) >> 3; @@ -406,7 +403,7 @@ BMessage *msg = Window()->CurrentMessage(); uint32 buttons = msg->FindInt32("buttons"); - object = ((GLObject*)fObjects.ItemAt(ObjectAtPoint(point))); + object = reinterpret_cast(fObjects.ItemAt(ObjectAtPoint(point))); if (object != NULL){ if (buttons == B_PRIMARY_MOUSE_BUTTON || buttons == B_SECONDARY_MOUSE_BUTTON) { @@ -506,18 +503,17 @@ void -ObjectView::FrameResized(float w, float h) +ObjectView::FrameResized(float width, float height) { LockGL(); - BGLView::FrameResized(w, h); + BGLView::FrameResized(width, height); + + width = Bounds().Width(); + height = Bounds().Height(); + fYxRatio = height / width; + glViewport(0, 0, (GLint)width + 1, (GLint)height + 1); - BRect b = Bounds(); - w = b.Width(); - h = b.Height(); - fYxRatio = h / w; - glViewport(0, 0, (GLint)w + 1, (GLint)h + 1); - // To prevent weird buffer contents glClear(GL_COLOR_BUFFER_BIT); @@ -590,6 +586,7 @@ ObjectView::EnforceState() { glShadeModel(fGouraud ? GL_SMOOTH : GL_FLAT); + if (fZbuf) glEnable(GL_DEPTH_TEST); else @@ -605,11 +602,10 @@ else glDisable(GL_LIGHTING); - if (fFilled) { + if (fFilled) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } else { - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - } + else + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); if (fFog) { glFogf(GL_FOG_START, 10.0); @@ -708,7 +704,7 @@ fForceRedraw = false; for (int i = 0; i < fObjects.CountItems(); i++) { - bool hack = ((GLObject*)fObjects.ItemAt(i))->SpinIt(); + bool hack = reinterpret_cast(fObjects.ItemAt(i))->SpinIt(); changed = changed || hack; } @@ -724,15 +720,15 @@ fObjListLock.Lock(); for (int i = 0; i < fObjects.CountItems(); i++) { - GLObject *o = ((GLObject*)fObjects.ItemAt(i)); - if (o->solidity == 0) - o->Draw(false, NULL); + GLObject *object = reinterpret_cast(fObjects.ItemAt(i)); + if (object->solidity == 0) + object->Draw(false, NULL); } EnforceState(); for (int i = 0; i < fObjects.CountItems(); i++) { - GLObject *o = ((GLObject*)fObjects.ItemAt(i)); - if (o->solidity != 0) - o->Draw(false, NULL); + GLObject *object = reinterpret_cast(fObjects.ItemAt(i)); + if (object->solidity != 0) + object->Draw(false, NULL); } fObjListLock.Unlock(); @@ -741,24 +737,26 @@ if (noPause) { uint64 now = system_time(); - float f = 1.0 / ((now - fLastFrame) / 1000000.0); + float fps = 1.0 / ((now - fLastFrame) / 1000000.0); fLastFrame = now; - int e; + int entry; if (fHistEntries < HISTSIZE) { - e = (fOldestEntry + fHistEntries) % HISTSIZE; + entry = (fOldestEntry + fHistEntries) % HISTSIZE; fHistEntries++; } else { - e = fOldestEntry; + entry = fOldestEntry; fOldestEntry = (fOldestEntry + 1) % HISTSIZE; } - fFpsHistory[e] = f; + fFpsHistory[entry] = fps; if (fHistEntries > 5) { - f = 0; + fps = 0; for (int i = 0; i < fHistEntries; i++) - f += fFpsHistory[(fOldestEntry + i) % HISTSIZE]; - f = f/fHistEntries; + fps += fFpsHistory[(fOldestEntry + i) % HISTSIZE]; + + fps /= fHistEntries; + if (fFps) { glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT); glPushMatrix(); @@ -774,7 +772,7 @@ glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - FPS::drawCounter(f); + FPS::drawCounter(fps); glMatrixMode(GL_PROJECTION); glPopMatrix(); Modified: haiku/trunk/src/apps/glteapot/ObjectView.h =================================================================== --- haiku/trunk/src/apps/glteapot/ObjectView.h 2008-02-23 11:54:34 UTC (rev 24076) +++ haiku/trunk/src/apps/glteapot/ObjectView.h 2008-02-23 13:41:57 UTC (rev 24077) @@ -9,17 +9,17 @@ #include #include -#define bmsgFPS 'fps ' -#define bmsgAddModel 'addm' -#define bmsgGouraud 'gour' -#define bmsgZBuffer 'zbuf' -#define bmsgCulling 'cull' -#define bmsgTextured 'txtr' -#define bmsgFog 'fog ' -#define bmsgLighting 'lite' -#define bmsgLights 'lits' -#define bmsgFilled 'fill' -#define bmsgPerspective 'prsp' +#define kMsgFPS 'fps ' +#define kMsgAddModel 'addm' +#define kMsgGouraud 'gour' +#define kMsgZBuffer 'zbuf' +#define kMsgCulling 'cull' +#define kMsgTextured 'txtr' +#define kMsgFog 'fog ' +#define kMsgLighting 'lite' +#define kMsgLights 'lits' +#define kMsgFilled 'fill' +#define kMsgPerspective 'prsp' enum lights { lightNone = 0, @@ -36,23 +36,23 @@ class GLObject; struct TrackingInfo { - float lastX; - float lastY; - float lastDx; - float lastDy; - bool isTracking; - GLObject *pickedObject; - uint32 buttons; + float lastX; + float lastY; + float lastDx; + float lastDy; + bool isTracking; + GLObject *pickedObject; + uint32 buttons; }; class ObjectView : public BGLView { public: - ObjectView(BRect r, char* name, ulong resizingMode, + ObjectView(BRect rect, char* name, ulong resizingMode, ulong options); ~ObjectView(); - virtual void MouseDown(BPoint p); - virtual void MouseUp(BPoint p); + virtual void MouseDown(BPoint point); + virtual void MouseUp(BPoint point); virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg); virtual void MessageReceived(BMessage* msg); @@ -60,7 +60,7 @@ virtual void DetachedFromWindow(); virtual void FrameResized(float width, float height); bool SpinIt(); - int ObjectAtPoint(BPoint p); + int ObjectAtPoint(const BPoint &point); virtual void DrawFrame(bool noPause); virtual void Pulse(); void EnforceState(); @@ -82,7 +82,7 @@ bool fLastPersp, fPersp, fLastTextured, fTextured; bool fLastFog, fFog, fForceRedraw; float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE]; - float fObjectDistance,fLastObjectDistance; + float fObjectDistance, fLastObjectDistance; TrackingInfo fTrackingInfo; }; Modified: haiku/trunk/src/apps/glteapot/TeapotWindow.cpp =================================================================== --- haiku/trunk/src/apps/glteapot/TeapotWindow.cpp 2008-02-23 11:54:34 UTC (rev 24076) +++ haiku/trunk/src/apps/glteapot/TeapotWindow.cpp 2008-02-23 13:41:57 UTC (rev 24077) @@ -11,154 +11,151 @@ #include "TeapotWindow.h" TeapotWindow::TeapotWindow(BRect rect, char* name, window_type wt, ulong something) - : BDirectWindow(rect,name,wt,something) + : BDirectWindow(rect, name, wt, something) { GLenum type = BGL_RGB | BGL_DEPTH | BGL_DOUBLE; - BRect r = rect; - r.OffsetTo(BPoint(100,100)); - Lock(); - r = Bounds(); - r.bottom = r.top + 14; - BMenuBar* mb = new BMenuBar(r,"main menu"); + BRect bounds = Bounds(); + bounds.bottom = bounds.top + 14; + BMenuBar* menuBar = new BMenuBar(bounds, "main menu"); - BMenu* m; - BMessage msg (bmsgAddModel); + BMenu* menu; + BMessage msg(kMsgAddModel); - mb->AddItem(m = new BMenu("File")); - AddChild(mb); + menuBar->AddItem(menu = new BMenu("File")); + AddChild(menuBar); - mb->ResizeToPreferred(); + menuBar->ResizeToPreferred(); - r = Bounds(); - r.top = mb->Bounds().bottom+1; - BView *sv = new BView(r,"subview",B_FOLLOW_ALL,0); - AddChild(sv); + bounds = Bounds(); + bounds.top = menuBar->Bounds().bottom + 1; + BView *subView = new BView(bounds, "subview", B_FOLLOW_ALL, 0); + AddChild(subView); - r = sv->Bounds(); - fObjectView = new ObjectView(r,"objectView", B_FOLLOW_ALL_SIDES,type); - sv->AddChild(fObjectView); + bounds = subView->Bounds(); + fObjectView = new ObjectView(bounds, "objectView", B_FOLLOW_ALL_SIDES, type); + subView->AddChild(fObjectView); fObjectView = fObjectView; BMenuItem* item; - msg.AddInt32("num",256); - m->AddItem(item = new BMenuItem("Add a teapot",new BMessage(msg), 'N')); + msg.AddInt32("num", 256); + menu->AddItem(item = new BMenuItem("Add a teapot", new BMessage(msg), 'N')); item->SetTarget(fObjectView); - m->AddSeparatorItem(); - m->AddItem(item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); + menu->AddSeparatorItem(); + menu->AddItem(item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); item->SetTarget(be_app); msg.RemoveName("num"); - mb->AddItem(m = new BMenu("Options")); - m->AddItem(item = new BMenuItem("Perspective",new BMessage(bmsgPerspective))); + menuBar->AddItem(menu = new BMenu("Options")); + menu->AddItem(item = new BMenuItem("Perspective", new BMessage(kMsgPerspective))); item->SetTarget(fObjectView); item->SetMarked(false); - m->AddItem(item = new BMenuItem("FPS Display",new BMessage(bmsgFPS))); + menu->AddItem(item = new BMenuItem("FPS Display", new BMessage(kMsgFPS))); item->SetTarget(fObjectView); item->SetMarked(true); - m->AddItem(item = new BMenuItem("Filled polygons",new BMessage(bmsgFilled))); + menu->AddItem(item = new BMenuItem("Filled polygons", new BMessage(kMsgFilled))); item->SetTarget(fObjectView); item->SetMarked(true); - m->AddItem(item = new BMenuItem("Lighting",new BMessage(bmsgLighting))); + menu->AddItem(item = new BMenuItem("Lighting", new BMessage(kMsgLighting))); item->SetTarget(fObjectView); item->SetMarked(true); - m->AddItem(item = new BMenuItem("Backface culling",new BMessage(bmsgCulling))); + menu->AddItem(item = new BMenuItem("Backface culling", new BMessage(kMsgCulling))); item->SetTarget(fObjectView); item->SetMarked(true); - m->AddItem(item = new BMenuItem("Z-buffered",new BMessage(bmsgZBuffer))); + menu->AddItem(item = new BMenuItem("Z-buffered", new BMessage(kMsgZBuffer))); item->SetTarget(fObjectView); item->SetMarked(true); - m->AddItem(item = new BMenuItem("Gouraud shading",new BMessage(bmsgGouraud))); + menu->AddItem(item = new BMenuItem("Gouraud shading", new BMessage(kMsgGouraud))); item->SetTarget(fObjectView); item->SetMarked(true); -// m->AddItem(item = new BMenuItem("Texture mapped",new BMessage(bmsgTextured))); +// menu->AddItem(item = new BMenuItem("Texture mapped", new BMessage(kMsgTextured))); // item->SetTarget(fObjectView); - m->AddItem(item = new BMenuItem("Fog",new BMessage(bmsgFog))); + menu->AddItem(item = new BMenuItem("Fog", new BMessage(kMsgFog))); item->SetTarget(fObjectView); - BMenu *sm; - mb->AddItem(m = new BMenu("Lights")); - msg.what = bmsgLights; + BMenu *subMenu; + menuBar->AddItem(menu = new BMenu("Lights")); + msg.what = kMsgLights; - msg.AddInt32("num",1); - m->AddItem(item = new BMenuItem(sm = new BMenu("Upper center"),NULL)); + msg.AddInt32("num", 1); + menu->AddItem(item = new BMenuItem(subMenu = new BMenu("Upper center"), NULL)); item->SetTarget(fObjectView); - msg.AddInt32("color",lightNone); - sm->AddItem(item = new BMenuItem("Off",new BMessage(msg))); + msg.AddInt32("color", lightNone); + subMenu->AddItem(item = new BMenuItem("Off", new BMessage(msg))); item->SetTarget(fObjectView); - sm->AddSeparatorItem(); - msg.ReplaceInt32("color",lightWhite); - sm->AddItem(item = new BMenuItem("White",new BMessage(msg))); + subMenu->AddSeparatorItem(); + msg.ReplaceInt32("color", lightWhite); + subMenu->AddItem(item = new BMenuItem("White", new BMessage(msg))); item->SetTarget(fObjectView); item->SetMarked(true); - msg.ReplaceInt32("color",lightYellow); - sm->AddItem(item = new BMenuItem("Yellow",new BMessage(msg))); + msg.ReplaceInt32("color", lightYellow); + subMenu->AddItem(item = new BMenuItem("Yellow", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightBlue); - sm->AddItem(item = new BMenuItem("Blue",new BMessage(msg))); + msg.ReplaceInt32("color", lightBlue); + subMenu->AddItem(item = new BMenuItem("Blue", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightRed); - sm->AddItem(item = new BMenuItem("Red",new BMessage(msg))); + msg.ReplaceInt32("color", lightRed); + subMenu->AddItem(item = new BMenuItem("Red", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightGreen); - sm->AddItem(item = new BMenuItem("Green",new BMessage(msg))); + msg.ReplaceInt32("color", lightGreen); + subMenu->AddItem(item = new BMenuItem("Green", new BMessage(msg))); item->SetTarget(fObjectView); msg.RemoveName("color"); - msg.ReplaceInt32("num",2); - m->AddItem(item = new BMenuItem(sm = new BMenu("Lower left"),NULL)); + msg.ReplaceInt32("num", 2); + menu->AddItem(item = new BMenuItem(subMenu = new BMenu("Lower left"), NULL)); item->SetTarget(fObjectView); - msg.AddInt32("color",lightNone); - sm->AddItem(item = new BMenuItem("Off",new BMessage(msg))); + msg.AddInt32("color", lightNone); + subMenu->AddItem(item = new BMenuItem("Off", new BMessage(msg))); item->SetTarget(fObjectView); - sm->AddSeparatorItem(); - msg.ReplaceInt32("color",lightWhite); - sm->AddItem(item = new BMenuItem("White",new BMessage(msg))); + subMenu->AddSeparatorItem(); + msg.ReplaceInt32("color", lightWhite); + subMenu->AddItem(item = new BMenuItem("White", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightYellow); - sm->AddItem(item = new BMenuItem("Yellow",new BMessage(msg))); + msg.ReplaceInt32("color", lightYellow); + subMenu->AddItem(item = new BMenuItem("Yellow", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightBlue); - sm->AddItem(item = new BMenuItem("Blue",new BMessage(msg))); + msg.ReplaceInt32("color", lightBlue); + subMenu->AddItem(item = new BMenuItem("Blue", new BMessage(msg))); item->SetTarget(fObjectView); item->SetMarked(true); - msg.ReplaceInt32("color",lightRed); - sm->AddItem(item = new BMenuItem("Red",new BMessage(msg))); + msg.ReplaceInt32("color", lightRed); + subMenu->AddItem(item = new BMenuItem("Red", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightGreen); - sm->AddItem(item = new BMenuItem("Green",new BMessage(msg))); + msg.ReplaceInt32("color", lightGreen); + subMenu->AddItem(item = new BMenuItem("Green", new BMessage(msg))); item->SetTarget(fObjectView); msg.RemoveName("color"); - msg.ReplaceInt32("num",3); - m->AddItem(item = new BMenuItem(sm = new BMenu("Right"),NULL)); + msg.ReplaceInt32("num", 3); + menu->AddItem(item = new BMenuItem(subMenu = new BMenu("Right"), NULL)); item->SetTarget(fObjectView); - msg.AddInt32("color",lightNone); - sm->AddItem(item = new BMenuItem("Off",new BMessage(msg))); + msg.AddInt32("color", lightNone); + subMenu->AddItem(item = new BMenuItem("Off", new BMessage(msg))); item->SetTarget(fObjectView); item->SetMarked(true); - sm->AddSeparatorItem(); - msg.ReplaceInt32("color",lightWhite); - sm->AddItem(item = new BMenuItem("White",new BMessage(msg))); + subMenu->AddSeparatorItem(); + msg.ReplaceInt32("color", lightWhite); + subMenu->AddItem(item = new BMenuItem("White", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightYellow); - sm->AddItem(item = new BMenuItem("Yellow",new BMessage(msg))); + msg.ReplaceInt32("color", lightYellow); + subMenu->AddItem(item = new BMenuItem("Yellow", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightBlue); - sm->AddItem(item = new BMenuItem("Blue",new BMessage(msg))); + msg.ReplaceInt32("color", lightBlue); + subMenu->AddItem(item = new BMenuItem("Blue", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightRed); - sm->AddItem(item = new BMenuItem("Red",new BMessage(msg))); + msg.ReplaceInt32("color", lightRed); + subMenu->AddItem(item = new BMenuItem("Red", new BMessage(msg))); item->SetTarget(fObjectView); - msg.ReplaceInt32("color",lightGreen); - sm->AddItem(item = new BMenuItem("Green",new BMessage(msg))); + msg.ReplaceInt32("color", lightGreen); + subMenu->AddItem(item = new BMenuItem("Green", new BMessage(msg))); item->SetTarget(fObjectView); - float f = mb->Bounds().IntegerHeight()+1; - SetSizeLimits(32,1024,32+f,1024+f); - + float f = menuBar->Bounds().IntegerHeight() + 1; + SetSizeLimits(32, 1024, 32 + f, 1024 + f); + //TODO: verify, adding an height to x seems strange Unlock(); } @@ -167,7 +164,7 @@ TeapotWindow::QuitRequested() { // printf("closing \n"); - fObjectView->EnableDirectMode( false ); + fObjectView->EnableDirectMode(false); be_app->PostMessage(B_QUIT_REQUESTED); return true; } @@ -177,8 +174,8 @@ TeapotWindow::DirectConnected(direct_buffer_info* info) { if (fObjectView) - fObjectView->DirectConnected( info ); - fObjectView->EnableDirectMode( true ); + fObjectView->DirectConnected(info); + fObjectView->EnableDirectMode(true); } From korli at mail.berlios.de Sat Feb 23 16:05:46 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 23 Feb 2008 16:05:46 +0100 Subject: [Haiku-commits] r24078 - in haiku/trunk/src/add-ons/translators: exr hpgs shared Message-ID: <200802231505.m1NF5kE4022138@sheep.berlios.de> Author: korli Date: 2008-02-23 16:05:45 +0100 (Sat, 23 Feb 2008) New Revision: 24078 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24078&view=rev Modified: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp haiku/trunk/src/add-ons/translators/hpgs/HPGSTranslator.cpp haiku/trunk/src/add-ons/translators/hpgs/ReadHelper.h haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h Log: HPGSTranslator now uses the class StreamBuffer adjusted StreamBuffer::Seek() to match BPositionIO API Modified: haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-23 13:41:57 UTC (rev 24077) +++ haiku/trunk/src/add-ons/translators/exr/IStreamWrapper.cpp 2008-02-23 15:05:45 UTC (rev 24078) @@ -39,5 +39,5 @@ void IStreamWrapper::seekg(Int64 pos) { - fStream.Seek(pos); + fStream.Seek(pos, SEEK_SET); } Modified: haiku/trunk/src/add-ons/translators/hpgs/HPGSTranslator.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/hpgs/HPGSTranslator.cpp 2008-02-23 13:41:57 UTC (rev 24077) +++ haiku/trunk/src/add-ons/translators/hpgs/HPGSTranslator.cpp 2008-02-23 15:05:45 UTC (rev 24078) @@ -129,8 +129,7 @@ free(reader); free(size_dev); - free(istream->stream); - free(istream); + hpgs_free_wrapper_istream(istream); return err; } Modified: haiku/trunk/src/add-ons/translators/hpgs/ReadHelper.h =================================================================== --- haiku/trunk/src/add-ons/translators/hpgs/ReadHelper.h 2008-02-23 13:41:57 UTC (rev 24077) +++ haiku/trunk/src/add-ons/translators/hpgs/ReadHelper.h 2008-02-23 15:05:45 UTC (rev 24078) @@ -9,9 +9,11 @@ #include #include +#include "StreamBuffer.h" + typedef struct my_hpgs_istream_st { - BPositionIO *stream; + StreamBuffer *buffer; status_t iseof; } my_hpgs_istream; @@ -22,7 +24,7 @@ unsigned char value; status_t error; stream->iseof = 0; - error = stream->stream->Read((void *)&value, sizeof(unsigned char)); + error = stream->buffer->Read((void *)&value, sizeof(unsigned char)); if (error > B_OK) return value; stream->iseof = EOF; @@ -33,7 +35,7 @@ static int positionio_ungetc(int c, my_hpgs_istream *stream) { - return stream->stream->Seek(-1, SEEK_CUR); + return stream->buffer->Seek(-1, SEEK_CUR); } @@ -61,7 +63,7 @@ static int positionio_tell(my_hpgs_istream *stream, size_t *pos) { - *pos = stream->stream->Position(); + *pos = stream->buffer->Position(); return 0; } @@ -69,7 +71,7 @@ static int positionio_seek(my_hpgs_istream *stream, size_t pos) { - stream->stream->Seek(pos, SEEK_SET); + stream->buffer->Seek(pos, SEEK_SET); return 0; } @@ -77,7 +79,7 @@ static int positionio_seekend(my_hpgs_istream *stream, size_t pos) { - stream->stream->Seek(pos, SEEK_END); + stream->buffer->Seek(pos, SEEK_END); return 0; } @@ -88,7 +90,7 @@ unsigned char *iptr = (unsigned char *)ptr; size_t i = 0; for (; i < nmemb; i++) { - if (size != stream->stream->Read(iptr, size)) + if (size != stream->buffer->Read(iptr, size)) break; iptr += size; } @@ -109,7 +111,8 @@ (hpgs_istream_seekend_func_t) positionio_seekend }; -hpgs_istream *hpgs_new_wrapper_istream(BPositionIO *stream) +hpgs_istream * +hpgs_new_wrapper_istream(BPositionIO *stream) { hpgs_istream *ret = (hpgs_istream *)malloc(sizeof(hpgs_istream)); @@ -119,9 +122,18 @@ ret->stream = (my_hpgs_istream *)malloc(sizeof(my_hpgs_istream)); ret->vtable = &positionio_vtable; ((my_hpgs_istream *)ret->stream)->iseof = 0; - ((my_hpgs_istream *)ret->stream)->stream = stream; + ((my_hpgs_istream *)ret->stream)->buffer = new StreamBuffer(stream, 2048); return ret; } + +void +hpgs_free_wrapper_istream(hpgs_istream *istream) +{ + delete ((my_hpgs_istream *)istream->stream)->buffer; + free(istream->stream); + free(istream); +} + #endif // READ_HELPER_H Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-23 13:41:57 UTC (rev 24077) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.cpp 2008-02-23 15:05:45 UTC (rev 24078) @@ -190,20 +190,36 @@ // // Postconditions: // -// Returns: true if the seek was successful, -// false if the seek operation failed +// Returns: the new position // --------------------------------------------------------------- -bool -StreamBuffer::Seek(off_t position) +off_t +StreamBuffer::Seek(off_t position, uint32 seekMode) { - fLen = 0; - fPos = 0; + // just seek in the current buffer if the new position is in it + if (seekMode == SEEK_CUR) { + if (fToRead + && (fPos + position < fLen) + && (fPos + position >= 0)) { + fPos += position; + return Position(); + } else if (!fToRead + && (fLen + position < fBufferSize) + && (fLen + position >= 0)) { + fLen += position; + return Position(); + } + } - if (fStream->Seek(position, SEEK_SET) == position) { - return true; + // flush if something to write + if (!fToRead + && fLen > 0) { + fStream->Write(fBuffer, fLen); } - return false; + fLen = 0; + fPos = 0; + + return fStream->Seek(position, seekMode); } Modified: haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h =================================================================== --- haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-23 13:41:57 UTC (rev 24077) +++ haiku/trunk/src/add-ons/translators/shared/StreamBuffer.h 2008-02-23 15:05:45 UTC (rev 24078) @@ -28,7 +28,7 @@ void Write(void *buffer, size_t size); // copy nbytes from the stream into pinto - bool Seek(off_t position); + off_t Seek(off_t position, uint32 seekMode); // seek the stream to the given position off_t Position(); From jackburton at mail.berlios.de Sat Feb 23 16:41:23 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 23 Feb 2008 16:41:23 +0100 Subject: [Haiku-commits] r24079 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802231541.m1NFfN5o026245@sheep.berlios.de> Author: jackburton Date: 2008-02-23 16:41:22 +0100 (Sat, 23 Feb 2008) New Revision: 24079 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24079&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: In the last commit I introduced a bug: charCount wasn't incremented correctly in some cases inside HashEscapements(). Also, when looking for a value in the hash, we checked the same position twice in some cases (did not cause any problem, was just a bit slower). Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-23 15:05:45 UTC (rev 24078) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-23 15:41:22 UTC (rev 24079) @@ -216,6 +216,7 @@ return position; } + /*! \brief Gets the escapement for the given charachter. \param value An integer which uniquely identifies a charachter. \param index The index of the table to search. @@ -300,13 +301,7 @@ const uint32 value = CharToCode(text, charLen); uint32 hashed = Hash(value) & (table.tableCount - 1); - uint32 found = widths[hashed].code; - - if (found == value) { - text += charLen; - continue; - } - + uint32 found; while ((found = widths[hashed].code) != kInvalidCode) { if (found == value) break; @@ -325,6 +320,7 @@ // the total size. if (table.tableCount * 2 / 3 <= table.hashCount) { const int32 newSize = table.tableCount * 2; + table.tableCount = newSize; // Create and initialize a new hash table hashed_escapement *newWidths = new hashed_escapement[newSize]; @@ -338,10 +334,8 @@ newPos = 0; } newWidths[newPos] = widths[oldPos]; - } } - table.tableCount = newSize; // Delete the old table, and put the new pointer into the _width_table_ delete[] widths; From bonefish at mail.berlios.de Sat Feb 23 16:56:57 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 23 Feb 2008 16:56:57 +0100 Subject: [Haiku-commits] r24080 - haiku/trunk/headers/private/kernel Message-ID: <200802231556.m1NFuvdR028327@sheep.berlios.de> Author: bonefish Date: 2008-02-23 16:56:56 +0100 (Sat, 23 Feb 2008) New Revision: 24080 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24080&view=rev Modified: haiku/trunk/headers/private/kernel/syscall_restart.h Log: * syscall_restart_handle_timeout_pre(uint32&, bigtime_t&): A huge negative relative timeout would be converted to B_INFINITE_TIMEOUT. For some reason the ScreenSaver preflet is snooze()ing with such a value. * Some more comments. Modified: haiku/trunk/headers/private/kernel/syscall_restart.h =================================================================== --- haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-23 15:41:22 UTC (rev 24079) +++ haiku/trunk/headers/private/kernel/syscall_restart.h 2008-02-23 15:56:56 UTC (rev 24080) @@ -10,6 +10,11 @@ #include +/*! Helper function for syscalls with relative timeout. + Converts the given relative timeout to an absolute timeout or retrieves + the value from the syscall restart parameters, if the syscall has been + restarted. A negative value means infinite timeout. +*/ static inline void syscall_restart_handle_timeout_pre(bigtime_t& timeout) { @@ -20,12 +25,18 @@ timeout = *(bigtime_t*)thread->syscall_restart.parameters; else if (timeout >= 0) { timeout += system_time(); + // deal with overflow if (timeout < 0) timeout = B_INFINITE_TIMEOUT; } } +/*! Helper function for syscalls with flags + timeout. + If necessary converts the given timeout to an absolute timeout or retrieves + the value from the syscall restart parameters, if the syscall has been + restarted. +*/ static inline void syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) { @@ -36,11 +47,12 @@ struct thread* thread = thread_get_current_thread(); if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) { timeout = *(bigtime_t*)thread->syscall_restart.parameters; - if (timeout != 0 && (flags & B_RELATIVE_TIMEOUT) != 0) + if (timeout > 0 && (flags & B_RELATIVE_TIMEOUT) != 0) flags = (flags & ~B_RELATIVE_TIMEOUT) | B_ABSOLUTE_TIMEOUT; } else if ((flags & B_RELATIVE_TIMEOUT) != 0) { - if (timeout != 0) { + if (timeout > 0) { timeout += system_time(); + // deal with overflow if (timeout < 0) timeout = B_INFINITE_TIMEOUT; From jackburton at mail.berlios.de Sat Feb 23 16:57:36 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 23 Feb 2008 16:57:36 +0100 Subject: [Haiku-commits] r24081 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802231557.m1NFvaDR028638@sheep.berlios.de> Author: jackburton Date: 2008-02-23 16:57:35 +0100 (Sat, 23 Feb 2008) New Revision: 24081 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24081&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp Log: avoid double function call. Modified: haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp 2008-02-23 15:56:56 UTC (rev 24080) +++ haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp 2008-02-23 15:57:35 UTC (rev 24081) @@ -230,9 +230,10 @@ { long numChars = *ioDelta; for (long i = 0; i < numChars; i++) { - if ((RealCharAt(fromIndex + i) & 0xc0) == 0x80) + char realChar = RealCharAt(fromIndex + i); + if ((realChar & 0xc0) == 0x80) continue; - if (RealCharAt(fromIndex + i) == inChar) { + if (realChar == inChar) { *ioDelta = i; return true; } From bonefish at mail.berlios.de Sat Feb 23 16:59:30 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 23 Feb 2008 16:59:30 +0100 Subject: [Haiku-commits] r24082 - haiku/trunk/src/system/kernel Message-ID: <200802231559.m1NFxUsB029139@sheep.berlios.de> Author: bonefish Date: 2008-02-23 16:59:30 +0100 (Sat, 23 Feb 2008) New Revision: 24082 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24082&view=rev Modified: haiku/trunk/src/system/kernel/wait_for_objects.cpp Log: common_select/poll(): Consider all negative timeout values as infinite timeout, not just -1. Paranoia only, since that should happen anyway. Modified: haiku/trunk/src/system/kernel/wait_for_objects.cpp =================================================================== --- haiku/trunk/src/system/kernel/wait_for_objects.cpp 2008-02-23 15:57:35 UTC (rev 24081) +++ haiku/trunk/src/system/kernel/wait_for_objects.cpp 2008-02-23 15:59:30 UTC (rev 24082) @@ -220,7 +220,7 @@ // wait for something to happen status = acquire_sem_etc(sync->sem, 1, - B_CAN_INTERRUPT | (timeout != -1 ? B_ABSOLUTE_TIMEOUT : 0), timeout); + B_CAN_INTERRUPT | (timeout >= 0 ? B_ABSOLUTE_TIMEOUT : 0), timeout); // restore the old signal mask if (sigMask != NULL) @@ -325,7 +325,7 @@ locker.Unlock(); status = acquire_sem_etc(sync->sem, 1, - B_CAN_INTERRUPT | (timeout != -1 ? B_ABSOLUTE_TIMEOUT : 0), timeout); + B_CAN_INTERRUPT | (timeout >= 0 ? B_ABSOLUTE_TIMEOUT : 0), timeout); // deselect file descriptors From bonefish at mail.berlios.de Sat Feb 23 17:02:00 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 23 Feb 2008 17:02:00 +0100 Subject: [Haiku-commits] r24083 - haiku/trunk/src/system/kernel Message-ID: <200802231602.m1NG20UL029449@sheep.berlios.de> Author: bonefish Date: 2008-02-23 17:01:59 +0100 (Sat, 23 Feb 2008) New Revision: 24083 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24083&view=rev Modified: haiku/trunk/src/system/kernel/sem.cpp Log: switch_sem_etc() doesn't check the return value of add_timer(), hence we need to make sure that we never get that far with a negative timeout or we'll wait forever. Modified: haiku/trunk/src/system/kernel/sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/sem.cpp 2008-02-23 15:59:30 UTC (rev 24082) +++ haiku/trunk/src/system/kernel/sem.cpp 2008-02-23 16:01:59 UTC (rev 24083) @@ -864,11 +864,16 @@ goto err; } - if (sSems[slot].u.used.count - count < 0 && (flags & B_RELATIVE_TIMEOUT) != 0 - && timeout <= 0) { - // immediate timeout - status = B_WOULD_BLOCK; - goto err; + if (sSems[slot].u.used.count - count < 0) { + if ((flags & B_RELATIVE_TIMEOUT) != 0 && timeout <= 0) { + // immediate timeout + status = B_WOULD_BLOCK; + goto err; + } else if ((flags & B_ABSOLUTE_TIMEOUT) != 0 && timeout < 0) { + // absolute negative timeout + status = B_TIMED_OUT; + goto err; + } } if ((sSems[slot].u.used.count -= count) < 0) { From stippi at mail.berlios.de Sat Feb 23 20:39:43 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 23 Feb 2008 20:39:43 +0100 Subject: [Haiku-commits] r24084 - haiku/trunk/src/servers/app/drawing Message-ID: <200802231939.m1NJdhne030645@sheep.berlios.de> Author: stippi Date: 2008-02-23 20:39:42 +0100 (Sat, 23 Feb 2008) New Revision: 24084 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24084&view=rev Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp Log: * Always use the double buffered implementation if running in VESA mode. It was not used in case of 32 bit VESA modes. Gives a huge performance boost for 32 bit VESA mode. Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2008-02-23 16:01:59 UTC (rev 24083) +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp 2008-02-23 19:39:42 UTC (rev 24084) @@ -576,8 +576,9 @@ // -> fall back to double buffer for fDisplayMode.space != B_RGB32 // as intermediate solution... bool doubleBuffered = HWInterface::IsDoubleBuffered(); - if ((color_space)fDisplayMode.space != B_RGB32 + if (((color_space)fDisplayMode.space != B_RGB32 && (color_space)fDisplayMode.space != B_RGBA32) + || fVGADevice > 0) doubleBuffered = true; if (doubleBuffered) { From korli at mail.berlios.de Sat Feb 23 23:31:21 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 23 Feb 2008 23:31:21 +0100 Subject: [Haiku-commits] r24085 - haiku/trunk/headers/posix Message-ID: <200802232231.m1NMVLvr022591@sheep.berlios.de> Author: korli Date: 2008-02-23 23:31:19 +0100 (Sat, 23 Feb 2008) New Revision: 24085 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24085&view=rev Modified: haiku/trunk/headers/posix/stdint.h Log: added SIZE_MAX to stdint.h Modified: haiku/trunk/headers/posix/stdint.h =================================================================== --- haiku/trunk/headers/posix/stdint.h 2008-02-23 19:39:42 UTC (rev 24084) +++ haiku/trunk/headers/posix/stdint.h 2008-02-23 22:31:19 UTC (rev 24085) @@ -120,7 +120,10 @@ typedef signed long long intmax_t; typedef unsigned long long uintmax_t; +/* Other types */ +#define SIZE_MAX UINT32_MAX + /* BSD compatibility */ typedef uint8_t u_int8_t; From korli at mail.berlios.de Sat Feb 23 23:38:20 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 23 Feb 2008 23:38:20 +0100 Subject: [Haiku-commits] r24086 - in haiku/trunk/src/bin/tar: . lib lib/uniwidth rmt src Message-ID: <200802232238.m1NMcK6k023129@sheep.berlios.de> Author: korli Date: 2008-02-23 23:37:49 +0100 (Sat, 23 Feb 2008) New Revision: 24086 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24086&view=rev Added: haiku/trunk/src/bin/tar/lib/Makefile.am haiku/trunk/src/bin/tar/lib/Makefile.in haiku/trunk/src/bin/tar/lib/alloca.in.h haiku/trunk/src/bin/tar/lib/argp-ba.c haiku/trunk/src/bin/tar/lib/argp-eexst.c haiku/trunk/src/bin/tar/lib/argp-fmtstream.c haiku/trunk/src/bin/tar/lib/argp-fmtstream.h haiku/trunk/src/bin/tar/lib/argp-fs-xinl.c haiku/trunk/src/bin/tar/lib/argp-help.c haiku/trunk/src/bin/tar/lib/argp-namefrob.h haiku/trunk/src/bin/tar/lib/argp-parse.c haiku/trunk/src/bin/tar/lib/argp-pin.c haiku/trunk/src/bin/tar/lib/argp-pv.c haiku/trunk/src/bin/tar/lib/argp-pvh.c haiku/trunk/src/bin/tar/lib/argp-xinl.c haiku/trunk/src/bin/tar/lib/argp.h haiku/trunk/src/bin/tar/lib/asnprintf.c haiku/trunk/src/bin/tar/lib/at-func.c haiku/trunk/src/bin/tar/lib/canonicalize-lgpl.c haiku/trunk/src/bin/tar/lib/canonicalize.h haiku/trunk/src/bin/tar/lib/chdir-long.c haiku/trunk/src/bin/tar/lib/chdir-long.h haiku/trunk/src/bin/tar/lib/close-stream.c haiku/trunk/src/bin/tar/lib/close-stream.h haiku/trunk/src/bin/tar/lib/closeout.c haiku/trunk/src/bin/tar/lib/closeout.h haiku/trunk/src/bin/tar/lib/config.charset haiku/trunk/src/bin/tar/lib/configmake.h haiku/trunk/src/bin/tar/lib/creat-safer.c haiku/trunk/src/bin/tar/lib/dirent.in.h haiku/trunk/src/bin/tar/lib/dirfd.c haiku/trunk/src/bin/tar/lib/dirfd.h haiku/trunk/src/bin/tar/lib/dup-safer.c haiku/trunk/src/bin/tar/lib/dup2.c haiku/trunk/src/bin/tar/lib/fchdir.c haiku/trunk/src/bin/tar/lib/fchmodat.c haiku/trunk/src/bin/tar/lib/fchown-stub.c haiku/trunk/src/bin/tar/lib/fchownat.c haiku/trunk/src/bin/tar/lib/fcntl--.h haiku/trunk/src/bin/tar/lib/fcntl-safer.h haiku/trunk/src/bin/tar/lib/fcntl.in.h haiku/trunk/src/bin/tar/lib/fd-safer.c haiku/trunk/src/bin/tar/lib/float+.h haiku/trunk/src/bin/tar/lib/float.in.h haiku/trunk/src/bin/tar/lib/fnmatch.c haiku/trunk/src/bin/tar/lib/fnmatch.h haiku/trunk/src/bin/tar/lib/fnmatch.in.h haiku/trunk/src/bin/tar/lib/fnmatch_loop.c haiku/trunk/src/bin/tar/lib/fpending.c haiku/trunk/src/bin/tar/lib/fpending.h haiku/trunk/src/bin/tar/lib/fstatat.c haiku/trunk/src/bin/tar/lib/getcwd.c haiku/trunk/src/bin/tar/lib/getdelim.c haiku/trunk/src/bin/tar/lib/getopt_int.h haiku/trunk/src/bin/tar/lib/getpagesize.h haiku/trunk/src/bin/tar/lib/gettime.c haiku/trunk/src/bin/tar/lib/gettimeofday.c haiku/trunk/src/bin/tar/lib/gnulib.mk haiku/trunk/src/bin/tar/lib/imaxtostr.c haiku/trunk/src/bin/tar/lib/intprops.h haiku/trunk/src/bin/tar/lib/inttostr.c haiku/trunk/src/bin/tar/lib/inttostr.h haiku/trunk/src/bin/tar/lib/inttypes.in.h haiku/trunk/src/bin/tar/lib/localcharset.c haiku/trunk/src/bin/tar/lib/localcharset.h haiku/trunk/src/bin/tar/lib/lstat.c haiku/trunk/src/bin/tar/lib/lstat.h haiku/trunk/src/bin/tar/lib/malloca.c haiku/trunk/src/bin/tar/lib/malloca.h haiku/trunk/src/bin/tar/lib/malloca.valgrind haiku/trunk/src/bin/tar/lib/mbchar.c haiku/trunk/src/bin/tar/lib/mbchar.h haiku/trunk/src/bin/tar/lib/mbscasecmp.c haiku/trunk/src/bin/tar/lib/mbuiter.h haiku/trunk/src/bin/tar/lib/memchr.c haiku/trunk/src/bin/tar/lib/mempcpy.c haiku/trunk/src/bin/tar/lib/memrchr.c haiku/trunk/src/bin/tar/lib/mkdirat.c haiku/trunk/src/bin/tar/lib/mkdtemp.c haiku/trunk/src/bin/tar/lib/offtostr.c haiku/trunk/src/bin/tar/lib/open-safer.c haiku/trunk/src/bin/tar/lib/openat-die.c haiku/trunk/src/bin/tar/lib/openat-priv.h haiku/trunk/src/bin/tar/lib/openat-proc.c haiku/trunk/src/bin/tar/lib/openat.c haiku/trunk/src/bin/tar/lib/openat.h haiku/trunk/src/bin/tar/lib/paxerror.c haiku/trunk/src/bin/tar/lib/paxexit.c haiku/trunk/src/bin/tar/lib/paxlib.h haiku/trunk/src/bin/tar/lib/paxnames.c haiku/trunk/src/bin/tar/lib/pipe-safer.c haiku/trunk/src/bin/tar/lib/printf-args.c haiku/trunk/src/bin/tar/lib/printf-args.h haiku/trunk/src/bin/tar/lib/printf-parse.c haiku/trunk/src/bin/tar/lib/printf-parse.h haiku/trunk/src/bin/tar/lib/readlink.c haiku/trunk/src/bin/tar/lib/ref-add.sin haiku/trunk/src/bin/tar/lib/ref-del.sin haiku/trunk/src/bin/tar/lib/regcomp.c haiku/trunk/src/bin/tar/lib/regex.c haiku/trunk/src/bin/tar/lib/regex.h haiku/trunk/src/bin/tar/lib/regex_internal.c haiku/trunk/src/bin/tar/lib/regex_internal.h haiku/trunk/src/bin/tar/lib/regexec.c haiku/trunk/src/bin/tar/lib/rmt-command.h haiku/trunk/src/bin/tar/lib/rmt.h haiku/trunk/src/bin/tar/lib/rpmatch.c haiku/trunk/src/bin/tar/lib/rtapelib.c haiku/trunk/src/bin/tar/lib/same-inode.h haiku/trunk/src/bin/tar/lib/setenv.c haiku/trunk/src/bin/tar/lib/setenv.h haiku/trunk/src/bin/tar/lib/sleep.c haiku/trunk/src/bin/tar/lib/stat-macros.h haiku/trunk/src/bin/tar/lib/stat-time.h haiku/trunk/src/bin/tar/lib/stdbool.in.h haiku/trunk/src/bin/tar/lib/stdint.in.h haiku/trunk/src/bin/tar/lib/stdio.in.h haiku/trunk/src/bin/tar/lib/stdlib.in.h haiku/trunk/src/bin/tar/lib/stdopen.c haiku/trunk/src/bin/tar/lib/stdopen.h haiku/trunk/src/bin/tar/lib/strchrnul.c haiku/trunk/src/bin/tar/lib/strdup.c haiku/trunk/src/bin/tar/lib/streq.h haiku/trunk/src/bin/tar/lib/strerror.c haiku/trunk/src/bin/tar/lib/string.in.h haiku/trunk/src/bin/tar/lib/strndup.c haiku/trunk/src/bin/tar/lib/strnlen.c haiku/trunk/src/bin/tar/lib/strnlen1.c haiku/trunk/src/bin/tar/lib/strnlen1.h haiku/trunk/src/bin/tar/lib/strtoimax.c haiku/trunk/src/bin/tar/lib/strtoll.c haiku/trunk/src/bin/tar/lib/strtoumax.c haiku/trunk/src/bin/tar/lib/sys_stat.in.h haiku/trunk/src/bin/tar/lib/sys_time.in.h haiku/trunk/src/bin/tar/lib/sysexits.h haiku/trunk/src/bin/tar/lib/sysexits.in.h haiku/trunk/src/bin/tar/lib/system-ioctl.h haiku/trunk/src/bin/tar/lib/system.h haiku/trunk/src/bin/tar/lib/tempname.c haiku/trunk/src/bin/tar/lib/tempname.h haiku/trunk/src/bin/tar/lib/time.in.h haiku/trunk/src/bin/tar/lib/timespec.h haiku/trunk/src/bin/tar/lib/uinttostr.c haiku/trunk/src/bin/tar/lib/umaxtostr.c haiku/trunk/src/bin/tar/lib/unistd--.h haiku/trunk/src/bin/tar/lib/unistd-safer.h haiku/trunk/src/bin/tar/lib/unistd.in.h haiku/trunk/src/bin/tar/lib/unitypes.h haiku/trunk/src/bin/tar/lib/uniwidth.h haiku/trunk/src/bin/tar/lib/uniwidth/ haiku/trunk/src/bin/tar/lib/uniwidth/cjk.h haiku/trunk/src/bin/tar/lib/uniwidth/width.c haiku/trunk/src/bin/tar/lib/unlinkdir.c haiku/trunk/src/bin/tar/lib/unlinkdir.h haiku/trunk/src/bin/tar/lib/unsetenv.c haiku/trunk/src/bin/tar/lib/utimens.c haiku/trunk/src/bin/tar/lib/utimens.h haiku/trunk/src/bin/tar/lib/vasnprintf.c haiku/trunk/src/bin/tar/lib/vasnprintf.h haiku/trunk/src/bin/tar/lib/verify.h haiku/trunk/src/bin/tar/lib/version-etc-fsf.c haiku/trunk/src/bin/tar/lib/version-etc.c haiku/trunk/src/bin/tar/lib/version-etc.h haiku/trunk/src/bin/tar/lib/vsnprintf.c haiku/trunk/src/bin/tar/lib/wchar.in.h haiku/trunk/src/bin/tar/lib/wctype.in.h haiku/trunk/src/bin/tar/lib/wcwidth.c haiku/trunk/src/bin/tar/lib/xalloc-die.c haiku/trunk/src/bin/tar/lib/xsize.h haiku/trunk/src/bin/tar/lib/xstrndup.c haiku/trunk/src/bin/tar/lib/xstrndup.h haiku/trunk/src/bin/tar/lib/xstrtol-error.c haiku/trunk/src/bin/tar/rmt/ haiku/trunk/src/bin/tar/rmt/Jamfile haiku/trunk/src/bin/tar/rmt/rmt.c haiku/trunk/src/bin/tar/src/transform.c Removed: haiku/trunk/src/bin/tar/lib/addext.c haiku/trunk/src/bin/tar/lib/alloca_.h haiku/trunk/src/bin/tar/lib/exit.h haiku/trunk/src/bin/tar/lib/getline.h haiku/trunk/src/bin/tar/lib/getndelim2.c haiku/trunk/src/bin/tar/lib/getndelim2.h haiku/trunk/src/bin/tar/lib/lchown.h haiku/trunk/src/bin/tar/lib/stdbool_.h haiku/trunk/src/bin/tar/lib/stpcpy.h haiku/trunk/src/bin/tar/lib/strcase.h haiku/trunk/src/bin/tar/lib/time_r.h haiku/trunk/src/bin/tar/lib/xstrdup.c haiku/trunk/src/bin/tar/src/localedir.h haiku/trunk/src/bin/tar/src/mangle.c haiku/trunk/src/bin/tar/src/rmt.c haiku/trunk/src/bin/tar/src/rmt.h haiku/trunk/src/bin/tar/src/rtapelib.c haiku/trunk/src/bin/tar/src/system.h Modified: haiku/trunk/src/bin/tar/COPYING haiku/trunk/src/bin/tar/Jamfile haiku/trunk/src/bin/tar/config.h haiku/trunk/src/bin/tar/lib/Jamfile haiku/trunk/src/bin/tar/lib/alloca.c haiku/trunk/src/bin/tar/lib/argmatch.c haiku/trunk/src/bin/tar/lib/argmatch.h haiku/trunk/src/bin/tar/lib/backupfile.c haiku/trunk/src/bin/tar/lib/backupfile.h haiku/trunk/src/bin/tar/lib/basename.c haiku/trunk/src/bin/tar/lib/chown.c haiku/trunk/src/bin/tar/lib/dirname.c haiku/trunk/src/bin/tar/lib/dirname.h haiku/trunk/src/bin/tar/lib/error.c haiku/trunk/src/bin/tar/lib/error.h haiku/trunk/src/bin/tar/lib/exclude.c haiku/trunk/src/bin/tar/lib/exclude.h haiku/trunk/src/bin/tar/lib/exitfail.c haiku/trunk/src/bin/tar/lib/exitfail.h haiku/trunk/src/bin/tar/lib/fileblocks.c haiku/trunk/src/bin/tar/lib/ftruncate.c haiku/trunk/src/bin/tar/lib/full-write.c haiku/trunk/src/bin/tar/lib/full-write.h haiku/trunk/src/bin/tar/lib/getdate.c haiku/trunk/src/bin/tar/lib/getdate.h haiku/trunk/src/bin/tar/lib/getdate.y haiku/trunk/src/bin/tar/lib/getline.c haiku/trunk/src/bin/tar/lib/getopt.c haiku/trunk/src/bin/tar/lib/getopt.h haiku/trunk/src/bin/tar/lib/getopt1.c haiku/trunk/src/bin/tar/lib/gettext.h haiku/trunk/src/bin/tar/lib/hash.c haiku/trunk/src/bin/tar/lib/hash.h haiku/trunk/src/bin/tar/lib/human.c haiku/trunk/src/bin/tar/lib/human.h haiku/trunk/src/bin/tar/lib/lchown.c haiku/trunk/src/bin/tar/lib/malloc.c haiku/trunk/src/bin/tar/lib/memset.c haiku/trunk/src/bin/tar/lib/mktime.c haiku/trunk/src/bin/tar/lib/modechange.c haiku/trunk/src/bin/tar/lib/modechange.h haiku/trunk/src/bin/tar/lib/obstack.c haiku/trunk/src/bin/tar/lib/obstack.h haiku/trunk/src/bin/tar/lib/pathmax.h haiku/trunk/src/bin/tar/lib/prepargs.c haiku/trunk/src/bin/tar/lib/quote.c haiku/trunk/src/bin/tar/lib/quote.h haiku/trunk/src/bin/tar/lib/quotearg.c haiku/trunk/src/bin/tar/lib/quotearg.h haiku/trunk/src/bin/tar/lib/realloc.c haiku/trunk/src/bin/tar/lib/rmdir.c haiku/trunk/src/bin/tar/lib/safe-read.c haiku/trunk/src/bin/tar/lib/safe-read.h haiku/trunk/src/bin/tar/lib/safe-write.c haiku/trunk/src/bin/tar/lib/safe-write.h haiku/trunk/src/bin/tar/lib/save-cwd.c haiku/trunk/src/bin/tar/lib/save-cwd.h haiku/trunk/src/bin/tar/lib/savedir.c haiku/trunk/src/bin/tar/lib/savedir.h haiku/trunk/src/bin/tar/lib/stpcpy.c haiku/trunk/src/bin/tar/lib/strcasecmp.c haiku/trunk/src/bin/tar/lib/stripslash.c haiku/trunk/src/bin/tar/lib/strncasecmp.c haiku/trunk/src/bin/tar/lib/strtol.c haiku/trunk/src/bin/tar/lib/strtoul.c haiku/trunk/src/bin/tar/lib/strtoull.c haiku/trunk/src/bin/tar/lib/time_r.c haiku/trunk/src/bin/tar/lib/unlocked-io.h haiku/trunk/src/bin/tar/lib/utime.c haiku/trunk/src/bin/tar/lib/waitpid.c haiku/trunk/src/bin/tar/lib/xalloc.h haiku/trunk/src/bin/tar/lib/xgetcwd.c haiku/trunk/src/bin/tar/lib/xgetcwd.h haiku/trunk/src/bin/tar/lib/xmalloc.c haiku/trunk/src/bin/tar/lib/xstrtol.c haiku/trunk/src/bin/tar/lib/xstrtol.h haiku/trunk/src/bin/tar/lib/xstrtoumax.c haiku/trunk/src/bin/tar/src/Jamfile haiku/trunk/src/bin/tar/src/arith.h haiku/trunk/src/bin/tar/src/buffer.c haiku/trunk/src/bin/tar/src/common.h haiku/trunk/src/bin/tar/src/compare.c haiku/trunk/src/bin/tar/src/create.c haiku/trunk/src/bin/tar/src/delete.c haiku/trunk/src/bin/tar/src/extract.c haiku/trunk/src/bin/tar/src/incremen.c haiku/trunk/src/bin/tar/src/list.c haiku/trunk/src/bin/tar/src/misc.c haiku/trunk/src/bin/tar/src/names.c haiku/trunk/src/bin/tar/src/sparse.c haiku/trunk/src/bin/tar/src/system.c haiku/trunk/src/bin/tar/src/tar.c haiku/trunk/src/bin/tar/src/tar.h haiku/trunk/src/bin/tar/src/tar.rdef haiku/trunk/src/bin/tar/src/update.c haiku/trunk/src/bin/tar/src/utf8.c haiku/trunk/src/bin/tar/src/xheader.c Log: updated tar to 1.19 - was harder than expected. Modified: haiku/trunk/src/bin/tar/COPYING =================================================================== --- haiku/trunk/src/bin/tar/COPYING 2008-02-23 22:31:19 UTC (rev 24085) +++ haiku/trunk/src/bin/tar/COPYING 2008-02-23 22:37:49 UTC (rev 24086) @@ -1,284 +1,626 @@ + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + TERMS AND CONDITIONS -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + 0. Definitions. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + "This License" refers to version 3 of the GNU General Public License. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + A "covered work" means either the unmodified Program or a work based +on the Program. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + 1. Source Code. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + The Corresponding Source for a work in source code form is that +same work. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + 2. Basic Permissions. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. + 14. Revised Versions of this License. - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest @@ -287,15 +629,15 @@ To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -304,37 +646,31 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with this program. If not, see . - Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. Modified: haiku/trunk/src/bin/tar/Jamfile =================================================================== --- haiku/trunk/src/bin/tar/Jamfile 2008-02-23 22:31:19 UTC (rev 24085) +++ haiku/trunk/src/bin/tar/Jamfile 2008-02-23 22:37:49 UTC (rev 24086) @@ -5,4 +5,5 @@ : -Wall -Wmissing-prototypes -Wsign-compare ] ; SubInclude HAIKU_TOP src bin tar lib ; +SubInclude HAIKU_TOP src bin tar rmt ; SubInclude HAIKU_TOP src bin tar src ; Modified: haiku/trunk/src/bin/tar/config.h =================================================================== --- haiku/trunk/src/bin/tar/config.h 2008-02-23 22:31:19 UTC (rev 24085) +++ haiku/trunk/src/bin/tar/config.h 2008-02-23 22:37:49 UTC (rev 24086) @@ -1,11 +1,27 @@ -/* config.h. Generated by configure. */ +/* config.h. Generated from config.hin by configure. */ /* config.hin. Generated from configure.ac by autoheader. */ -#undef DEBUG +/* Define to the number of bits in type 'ptrdiff_t'. */ +#define BITSIZEOF_PTRDIFF_T 32 -/* Define to 1 if the `closedir' function returns void instead of `int'. */ -/* #undef CLOSEDIR_VOID */ +/* Define to the number of bits in type 'sig_atomic_t'. */ +#define BITSIZEOF_SIG_ATOMIC_T 32 +/* Define to the number of bits in type 'size_t'. */ +#define BITSIZEOF_SIZE_T 32 + +/* Define to the number of bits in type 'wchar_t'. */ +#define BITSIZEOF_WCHAR_T 16 + +/* Define to the number of bits in type 'wint_t'. */ +#define BITSIZEOF_WINT_T 32 + +/* Define if chown is not POSIX compliant regarding IDs of -1. */ +#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1 + +/* Define if chown modifies symlinks. */ +/* #undef CHOWN_MODIFIES_SYMLINK */ + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -23,52 +39,106 @@ /* Define to a number giving the default blocking size for archives. */ #define DEFAULT_BLOCKING 20 -/* - [Define], [to], [1], [if], [density], [may], [be], [indicated], [by], [[lmh]], [at], [end], [of], [device.] - */ +/* Define to a default quoting style (see lib/quoteargs.c for the list) */ +#define DEFAULT_QUOTING_STYLE escape_quoting_style + +/* Define full file name of rmt program. */ +/* #undef DEFAULT_RMT_COMMAND */ + +/* Define to 1 if density may be indicated by [lmh] at end of device. */ /* #undef DENSITY_LETTER */ /* Define to a string giving the prefix of the default device, without the part specifying the unit and density. */ /* #undef DEVICE_PREFIX */ -/* Define if there is a member named d_ino in the struct describing directory [... truncated: 81345 lines follow ...] From stippi at mail.berlios.de Sun Feb 24 10:43:11 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 10:43:11 +0100 Subject: [Haiku-commits] r24087 - haiku/trunk/build/jam Message-ID: <200802240943.m1O9hBFG009176@sheep.berlios.de> Author: stippi Date: 2008-02-24 10:43:10 +0100 (Sun, 24 Feb 2008) New Revision: 24087 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24087&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: applied patch by Maurice Kalinowski: Do not attempt to install optional 3rd party packages when building a GCC4 version of Haiku. I think there has been some discussion on this topic before, with a more advanced solution, but for the time being, this should be ok. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-02-23 22:37:49 UTC (rev 24086) +++ haiku/trunk/build/jam/HaikuImage 2008-02-24 09:43:10 UTC (rev 24087) @@ -513,53 +513,73 @@ # Vision if [ IsOptionalHaikuImagePackageAdded Vision ] { - InstallOptionalHaikuImagePackage Vision - : http://vision.sf.net/Vision-0.9.7-H-26012008.zip - : apps - ; - AddSymlinkToHaikuImage home config be Applications - : /boot/apps/Vision-0.9.7-H-26012008/Vision ; + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package Vision available for gcc4" ; + } else { + InstallOptionalHaikuImagePackage Vision + : http://vision.sf.net/Vision-0.9.7-H-26012008.zip + : apps + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/apps/Vision-0.9.7-H-26012008/Vision ; + } } # WonderBrush if [ IsOptionalHaikuImagePackageAdded WonderBrush ] { - InstallOptionalHaikuImagePackage WonderBrush - : http://www.yellowbites.com/downloads/WonderBrush-2.1.1-demo-x86-R5.zip - : apps - ; - AddSymlinkToHaikuImage home config be Applications - : /boot/apps/WonderBrush/WonderBrush ; + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package WonderBrush available for gcc4" ; + } else { + InstallOptionalHaikuImagePackage WonderBrush + : http://www.yellowbites.com/downloads/WonderBrush-2.1.1-demo-x86-R5.zip + : apps + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/apps/WonderBrush/WonderBrush ; + } } # OpenSound drivers if [ IsOptionalHaikuImagePackageAdded OpenSound ] { - InstallOptionalHaikuImagePackage OpenSound - : http://revolf.free.fr/beos/oss-beos-v4.1test-bin.zip - : - ; + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package OpenSound available for gcc4" ; + } else { + InstallOptionalHaikuImagePackage OpenSound + : http://revolf.free.fr/beos/oss-beos-v4.1test-bin.zip + : + ; + } #UnzipArchiveToHaikuImage home : data/vv.mp3.zip : 0 ; } # Links web browser if [ IsOptionalHaikuImagePackageAdded Links ] { - InstallOptionalHaikuImagePackage Links - : http://revolf.free.fr/beos/links-beos-bin.zip - : - ; - AddSymlinkToHaikuImage home config be Applications - : /boot/home/config/bin/links ; + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package Links available for gcc4" ; + } else { + InstallOptionalHaikuImagePackage Links + : http://revolf.free.fr/beos/links-beos-bin.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/home/config/bin/links ; + } } # Pe text editor if [ IsOptionalHaikuImagePackageAdded Pe ] { - InstallOptionalHaikuImagePackage Pe - : http://dl.hirschkaefer.de/beos/pe-2.4-x86.zip - : apps - ; - AddSymlinkToHaikuImage home config be Applications - : /boot/apps/pe-2.4-x86/pe ; - AddSymlinkToHaikuImage home config bin - : /boot/apps/pe-2.4-x86/lpe ; + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package Pe available for gcc4" ; + } else { + InstallOptionalHaikuImagePackage Pe + : http://dl.hirschkaefer.de/beos/pe-2.4-x86.zip + : apps + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/apps/pe-2.4-x86/pe ; + AddSymlinkToHaikuImage home config bin + : /boot/apps/pe-2.4-x86/lpe ; + } } #pragma mark - Build The Image From mmu_man at mail.berlios.de Sun Feb 24 10:44:10 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 24 Feb 2008 10:44:10 +0100 Subject: [Haiku-commits] r24088 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam Message-ID: <200802240944.m1O9iAKh009278@sheep.berlios.de> Author: mmu_man Date: 2008-02-24 10:44:10 +0100 (Sun, 24 Feb 2008) New Revision: 24088 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24088&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp Log: This has to fix the bug triggering the ASSERT in BMediaRoster::RegisterNode... Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-02-24 09:43:10 UTC (rev 24087) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-02-24 09:44:10 UTC (rev 24088) @@ -133,7 +133,7 @@ /* At most one instance of the node should be instantiated at any given * time. The locking for this restriction may be found in the VideoProducer * class. */ - node = new VideoProducer(this, cam, cam->FlavorInfo()->name, fDefaultFlavorInfo.internal_id); + node = new VideoProducer(this, cam, cam->FlavorInfo()->name, cam->FlavorInfo()->internal_id); if (node && (node->InitCheck() < B_OK)) { delete node; node = NULL; From stippi at mail.berlios.de Sun Feb 24 10:55:46 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 10:55:46 +0100 Subject: [Haiku-commits] r24089 - haiku/trunk/src/servers/media Message-ID: <200802240955.m1O9tjpL009965@sheep.berlios.de> Author: stippi Date: 2008-02-24 10:55:44 +0100 (Sun, 24 Feb 2008) New Revision: 24089 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24089&view=rev Modified: haiku/trunk/src/servers/media/MMediaFilesManager.cpp Log: applied patch by Maurice Kalinowski: * Add check whether directory to store settings exists. If not, create it. * Use global constant (like in DefaultManager.cpp) for path/file names. * Cleaned up a little bit and made debug output only appear in case debugging is turned on (meaning printf->TRACE). -> Fixes #1531. (I added a few more error checks to the code, maybe there should be even more...) Modified: haiku/trunk/src/servers/media/MMediaFilesManager.cpp =================================================================== --- haiku/trunk/src/servers/media/MMediaFilesManager.cpp 2008-02-24 09:44:10 UTC (rev 24088) +++ haiku/trunk/src/servers/media/MMediaFilesManager.cpp 2008-02-24 09:55:44 UTC (rev 24089) @@ -2,17 +2,23 @@ * Copyright 2003, J?r?me Duval. All rights reserved. * Distributed under the terms of the MIT License. */ +#include "debug.h" +#include "MMediaFilesManager.h" +#include "MediaSounds.h" + #include #include +#include +#include #include +#include #include -#include -#include -#include "MMediaFilesManager.h" -#include "MediaSounds.h" -#include "debug.h" +const char *kMediaFilesManagerSettingsDirectory = "Media"; +const char *kMediaFilesManagerSettingsFile = "MMediaFilesManager"; + + MMediaFilesManager::MMediaFilesManager() : fLocker(new BLocker("media files manager locker")), fRegistryMap(new Map >), @@ -40,6 +46,7 @@ #endif } + MMediaFilesManager::~MMediaFilesManager() { CALLED(); @@ -91,13 +98,15 @@ MMediaFilesManager::LoadState() { CALLED(); - status_t err = B_OK; BPath path; - if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK) + status_t err = find_directory(B_USER_SETTINGS_DIRECTORY, &path); + if (err >= B_OK) + err = path.Append(kMediaFilesManagerSettingsDirectory); + if (err >= B_OK) + err = path.Append(kMediaFilesManagerSettingsFile); + if (err < B_OK) return err; - path.Append("Media/MMediaFilesManager"); - BFile file(path.Path(), B_READ_ONLY); uint32 category_count; @@ -160,13 +169,19 @@ MMediaFilesManager::SaveState() { CALLED(); - status_t err = B_OK; BPath path; - if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK) + status_t err = find_directory(B_USER_SETTINGS_DIRECTORY, &path); + if (err >= B_OK) + err = path.Append(kMediaFilesManagerSettingsDirectory); + if (err >= B_OK) { + err = create_directory(path.Path(), + S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + } + if (err >= B_OK) + err = path.Append(kMediaFilesManagerSettingsFile); + if (err < B_OK) return err; - path.Append("Media/MMediaFilesManager"); - BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); uint32 zero = 0; @@ -206,11 +221,10 @@ MMediaFilesManager::Dump() { BAutolock lock(fLocker); - printf("\n"); /* for each type, the registry map contains a map of item/entry_ref */ - printf("MMediaFilesManager: registry map follows\n"); + TRACE("MMediaFilesManager: registry map follows\n"); BString *type = NULL; Map *map; BString *item = NULL; @@ -221,13 +235,11 @@ for (map->Rewind(); map->GetNext(&ref);) { map->GetCurrentKey(&item); BPath path(ref); - printf(" type \"%s\", item \"%s\", path \"%s\"\n", + TRACE(" type \"%s\", item \"%s\", path \"%s\"\n", type->String(), item->String(), (path.InitCheck() == B_OK) ? path.Path() : "INVALID"); } } - printf("MMediaFilesManager: list end\n"); - printf("\n"); - + TRACE("MMediaFilesManager: list end\n"); } From axeld at mail.berlios.de Sun Feb 24 12:18:53 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 24 Feb 2008 12:18:53 +0100 Subject: [Haiku-commits] r24090 - in haiku/trunk: headers/private/interface src/apps/workspaces src/servers/app Message-ID: <200802241118.m1OBIr0P019724@sheep.berlios.de> Author: axeld Date: 2008-02-24 12:18:52 +0100 (Sun, 24 Feb 2008) New Revision: 24090 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24090&view=rev Modified: haiku/trunk/headers/private/interface/ViewPrivate.h haiku/trunk/src/apps/workspaces/Workspaces.cpp haiku/trunk/src/servers/app/Desktop.cpp haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/ViewLayer.h haiku/trunk/src/servers/app/WorkspacesLayer.cpp Log: * First steps towards a more flexible workspaces view handling: the workspaces view can now be any view in the hierarchy. * Added private view flag kWorkspacesViewFlag that identifies such a view - note though, that you must not remove a view before closing or hiding its window for now (and that you still need to set the kWorkspacesWindowFlag, too). * Fixed Workspaces check for valid screen coordinates; after a crash, it managed to open its window offscreen for me. * Added a ViewLayer method FindView() that finds a view with the specified flags set. Modified: haiku/trunk/headers/private/interface/ViewPrivate.h =================================================================== --- haiku/trunk/headers/private/interface/ViewPrivate.h 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/headers/private/interface/ViewPrivate.h 2008-02-24 11:18:52 UTC (rev 24090) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku. + * Copyright 2003-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -10,8 +10,6 @@ #define VIEW_PRIVATE_H -#include - #include #include #include @@ -20,6 +18,9 @@ const static uint32 kDeleteReplicant = 'JAHA'; +const static uint32 kWorkspacesViewFlag = 0x40000000UL; + // was/is _B_RESERVED1_ in View.h + enum { B_VIEW_FONT_BIT = 0x00000001, B_VIEW_HIGH_COLOR_BIT = 0x00000002, @@ -48,6 +49,8 @@ namespace BPrivate { +class PortLink; + class ViewState { public: ViewState(); Modified: haiku/trunk/src/apps/workspaces/Workspaces.cpp =================================================================== --- haiku/trunk/src/apps/workspaces/Workspaces.cpp 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/apps/workspaces/Workspaces.cpp 2008-02-24 11:18:52 UTC (rev 24090) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku, Inc. + * Copyright 2002-2008, Haiku, Inc. * Copyright 2002, Fran?ois Revol, revol at free.fr. * This file is distributed under the terms of the MIT License. * @@ -32,8 +32,10 @@ #include #include -#include "WindowPrivate.h" +#include +#include + static const char *kWorkspacesSignature = "application/x-vnd.Be-WORK"; static const char *kWorkspacesSettingFile = "Workspace_data"; @@ -63,6 +65,7 @@ virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); + virtual void MouseDown(BPoint where); }; class WorkspacesWindow : public BWindow { @@ -126,9 +129,10 @@ } // check if loaded values are valid - if (screen.Frame().right >= fWindowFrame.right - && screen.Frame().bottom >= fWindowFrame.bottom - && fWindowFrame.right > 0 && fWindowFrame.bottom > 0) + if (screen.Frame().right + 5 >= fWindowFrame.right + && screen.Frame().bottom + 5 >= fWindowFrame.bottom + && screen.Frame().left - 5 <= fWindowFrame.left + && screen.Frame().top - 5 <= fWindowFrame.top) settingsValid = true; } } @@ -200,7 +204,7 @@ WorkspacesView::WorkspacesView(BRect frame) - : BView(frame, "workspaces", 0, B_FOLLOW_NONE) + : BView(frame, "workspaces", B_FOLLOW_NONE, kWorkspacesViewFlag) { } @@ -231,6 +235,20 @@ } +void +WorkspacesView::MouseDown(BPoint where) +{ + int32 buttons = 0; + if (Window() != NULL && Window()->CurrentMessage() != NULL) + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + + if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) + return; + + // TODO: open menu +} + + // #pragma mark - @@ -241,7 +259,7 @@ B_ALL_WORKSPACES), fPreferences(preferences) { - AddChild(new WorkspacesView(BRect(-10, -10, -5, -5))); + AddChild(new WorkspacesView(Bounds())); fPreviousFrame = Frame(); } Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/servers/app/Desktop.cpp 2008-02-24 11:18:52 UTC (rev 24090) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -29,6 +29,7 @@ #include "Workspace.h" #include "WorkspacesLayer.h" +#include #include #include @@ -1598,8 +1599,11 @@ return; } - if (WorkspacesLayer* layer = dynamic_cast(window->TopLayer())) - fWorkspacesLayer = layer; + if ((window->Flags() & kWorkspacesWindowFlag) != 0) { + // find workspaces layer in view hierarchy + fWorkspacesLayer = dynamic_cast( + window->TopLayer()->FindView(kWorkspacesViewFlag)); + } UnlockAllWindows(); @@ -1637,7 +1641,7 @@ if (fWorkspacesLayer != NULL) fWorkspacesLayer->WindowRemoved(window); - if (dynamic_cast(window->TopLayer()) != NULL) + if ((window->Flags() & kWorkspacesWindowFlag) != 0) fWorkspacesLayer = NULL; UnlockAllWindows(); Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2008-02-24 11:18:52 UTC (rev 24090) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -561,9 +562,10 @@ ViewLayer* newLayer; - if (link.Code() == AS_LAYER_CREATE_ROOT - && (fWindowLayer->Flags() & kWorkspacesWindowFlag) != 0) { - // this is a workspaces window! + if ((fWindowLayer->Flags() & kWorkspacesWindowFlag) != 0 + && (flags & kWorkspacesViewFlag) != 0) { + // TODO: there can currently only be one of these views per desktop! + // TODO: get rid of the kWorkspacesWindowFlag newLayer = new (nothrow) WorkspacesLayer(frame, scrollingOffset, name, token, resizeMask, flags); } else { Modified: haiku/trunk/src/servers/app/ViewLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.cpp 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/servers/app/ViewLayer.cpp 2008-02-24 11:18:52 UTC (rev 24090) @@ -377,6 +377,22 @@ ViewLayer* +ViewLayer::FindView(uint32 flags) +{ + if ((Flags() & flags) == flags) + return this; + + for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) { + ViewLayer* layer = child->FindView(flags); + if (layer != NULL) + return layer; + } + + return NULL; +} + + +ViewLayer* ViewLayer::ViewAt(const BPoint& where) { if (!fVisible) Modified: haiku/trunk/src/servers/app/ViewLayer.h =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.h 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/servers/app/ViewLayer.h 2008-02-24 11:18:52 UTC (rev 24090) @@ -100,6 +100,7 @@ uint32 CountChildren(bool deep = false) const; void CollectTokensForChildren(BList* tokenMap) const; + ViewLayer* FindView(uint32 flags); ViewLayer* ViewAt(const BPoint& where); Modified: haiku/trunk/src/servers/app/WorkspacesLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/WorkspacesLayer.cpp 2008-02-24 09:55:44 UTC (rev 24089) +++ haiku/trunk/src/servers/app/WorkspacesLayer.cpp 2008-02-24 11:18:52 UTC (rev 24090) @@ -33,6 +33,7 @@ WorkspacesLayer::~WorkspacesLayer() { + // TODO: we actually need to tell the Desktop that we're gone } @@ -74,21 +75,25 @@ int32 columns, rows; _GetGrid(columns, rows); - int32 width = Frame().IntegerWidth() / columns; - int32 height = Frame().IntegerHeight() / rows; + BRect frame = Bounds(); + ConvertToScreen(&frame); + int32 width = frame.IntegerWidth() / columns; + int32 height = frame.IntegerHeight() / rows; + int32 column = i % columns; int32 row = i / columns; - BRect rect(column * width, row * height, (column + 1) * width, (row + 1) * height); + BRect rect(column * width, row * height, (column + 1) * width, + (row + 1) * height); - rect.OffsetBy(Frame().LeftTop()); + rect.OffsetBy(frame.LeftTop()); // make sure there is no gap anywhere if (column == columns - 1) - rect.right = Frame().right; + rect.right = frame.right; if (row == rows - 1) - rect.bottom = Frame().bottom; + rect.bottom = frame.bottom; return rect; } @@ -288,7 +293,10 @@ void WorkspacesLayer::_Invalidate() const { - BRegion region((BRect)Frame()); + BRect frame = Bounds(); + ConvertToScreen(&frame); + + BRegion region(frame); Window()->MarkContentDirty(region); } @@ -314,8 +322,8 @@ gridRegion.Exclude(activeRect); drawingEngine->ConstrainClippingRegion(&gridRegion); - BRect frame = Frame(); - // top ViewLayer frame is in screen coordinates + BRect frame = Bounds(); + ConvertToScreen(&frame); // horizontal lines From korli at mail.berlios.de Sun Feb 24 14:41:01 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 24 Feb 2008 14:41:01 +0100 Subject: [Haiku-commits] r24091 - haiku/trunk/headers/posix Message-ID: <200802241341.m1ODf1T4019971@sheep.berlios.de> Author: korli Date: 2008-02-24 14:41:01 +0100 (Sun, 24 Feb 2008) New Revision: 24091 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24091&view=rev Added: haiku/trunk/headers/posix/search.h Log: added search.h Added: haiku/trunk/headers/posix/search.h =================================================================== --- haiku/trunk/headers/posix/search.h 2008-02-24 11:18:52 UTC (rev 24090) +++ haiku/trunk/headers/posix/search.h 2008-02-24 13:41:01 UTC (rev 24091) @@ -0,0 +1,45 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SEARCH_H_ +#define _SEARCH_H_ + +typedef enum { + FIND, + ENTER +} ACTION; + +typedef struct entry { + char *keyr; + void *data; +} ENTRY; + +typedef enum { + preorder, + postorder, + endorder, + leaf +} VISIT; + + +extern int hcreate(size_t); +extern void hdestroy(void); +extern ENTRY *hsearch(ENTRY, ACTION); +extern void insque(void *, void *); +extern void *lfind(const void *, const void *, size_t *, + size_t, int (*)(const void *, const void *)); +extern void *lsearch(const void *, void *, size_t *, + size_t, int (*)(const void *, const void *)); +extern void remque(void *); +extern void *tdelete(const void *restrict, void **restrict, + int(*)(const void *, const void *)); +extern void *tfind(const void *, void *const *, + int(*)(const void *, const void *)); +extern void *tsearch(const void *, void **, + int(*)(const void *, const void *)); +extern void twalk(const void *, + void (*)(const void *, VISIT, int )); + +#endif /* _SEARCH_H_ */ + From stippi at mail.berlios.de Sun Feb 24 15:15:29 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 15:15:29 +0100 Subject: [Haiku-commits] r24092 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200802241415.m1OEFT8x022807@sheep.berlios.de> Author: stippi Date: 2008-02-24 15:15:28 +0100 (Sun, 24 Feb 2008) New Revision: 24092 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24092&view=rev Modified: haiku/trunk/headers/os/interface/ListItem.h haiku/trunk/headers/os/interface/ListView.h haiku/trunk/src/kits/interface/ListItem.cpp haiku/trunk/src/kits/interface/ListView.cpp haiku/trunk/src/kits/interface/OutlineListView.cpp Log: patch by Rene Gollent: * BListItems now store the top offset of the frame within the parent BListView. * This allows binary searching the clicked item. * ItemFrame() is now a cheap call. * Fixed several bugs in the sorting code of BOutlineListView which lead to crashes of client applications. * Implemented previously unimplemented functions in BOutlineListView. Modified: haiku/trunk/headers/os/interface/ListItem.h =================================================================== --- haiku/trunk/headers/os/interface/ListItem.h 2008-02-24 13:41:01 UTC (rev 24091) +++ haiku/trunk/headers/os/interface/ListItem.h 2008-02-24 14:15:28 UTC (rev 24092) @@ -18,7 +18,8 @@ class BListItem : public BArchivable { public: - BListItem(uint32 outlineLevel = 0, bool expanded = true); + BListItem(uint32 outlineLevel = 0, + bool expanded = true); BListItem(BMessage* archive); virtual ~BListItem(); @@ -47,7 +48,7 @@ private: friend class BOutlineListView; - + friend class BListView; bool HasSubitems() const; virtual void _ReservedListItem1(); @@ -58,9 +59,11 @@ bool IsItemVisible() const; void SetItemVisible(bool visible); - + inline float Top() const; + inline float Bottom() const; + void SetTop(float top); private: - uint32 _reserved[1]; + float fTop; BList* fTemporaryList; float fWidth; float fHeight; @@ -72,6 +75,18 @@ bool fVisible : 1; }; +inline float +BListItem::Top(void) const +{ + return fTop; +} + +inline float +BListItem::Bottom(void) const +{ + return (fTop + ceilf(fHeight) - 1.0); +} + #include // to maintain source compatibility Modified: haiku/trunk/headers/os/interface/ListView.h =================================================================== --- haiku/trunk/headers/os/interface/ListView.h 2008-02-24 13:41:01 UTC (rev 24091) +++ haiku/trunk/headers/os/interface/ListView.h 2008-02-24 14:15:28 UTC (rev 24092) @@ -43,8 +43,8 @@ virtual void MakeFocus(bool state = true); virtual void FrameResized(float newWidth, float newHeight); virtual void TargetedByScrollView(BScrollView* scroller); - void ScrollTo(float x, float y); virtual void ScrollTo(BPoint where); + inline void ScrollTo(float x, float y); virtual bool AddItem(BListItem* item); virtual bool AddItem(BListItem* item, int32 atIndex); virtual bool AddList(BList* newItems); @@ -136,7 +136,6 @@ }; virtual bool DoMiscellaneous(MiscCode code, MiscData *data); - private: friend class BOutlineListView; @@ -161,6 +160,7 @@ bool _TryInitiateDrag(BPoint where); int32 _CalcFirstSelected(int32 after); int32 _CalcLastSelected(int32 before); + void _RecalcItemTops(int32 start); virtual void DrawItem(BListItem* item, BRect itemRect, bool complete = false); @@ -174,12 +174,11 @@ int32 fFirstSelected; int32 fLastSelected; int32 fAnchorIndex; - float fWidth; BMessage* fSelectMessage; BScrollView* fScrollView; track_data* fTrack; - uint32 _reserved[3]; + uint32 _reserved[4]; }; inline void Modified: haiku/trunk/src/kits/interface/ListItem.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListItem.cpp 2008-02-24 13:41:01 UTC (rev 24091) +++ haiku/trunk/src/kits/interface/ListItem.cpp 2008-02-24 14:15:28 UTC (rev 24092) @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. +// Copyright (c) 2001-2008, Haiku, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -21,7 +21,8 @@ // // File Name: ListItem.cpp // Author: Ulrich Wimboeck -// Marc Flerackers (mflerackers at androme.be) +// Marc Flerackers (mflerackers at androme.be) +// Rene Gollent // Description: BListItem is the base class for BListView's items, // BStringItem is a subclass of BListItem which draws a string. //------------------------------------------------------------------------------ @@ -34,7 +35,8 @@ BListItem::BListItem(uint32 level, bool expanded) - : fWidth(0), + : fTop(0.0), + fWidth(0), fHeight(0), fLevel(level), fSelected(false), @@ -48,6 +50,7 @@ BListItem::BListItem(BMessage *data) : BArchivable(data), + fTop(0.0), fWidth(0), fHeight(0), fLevel(0), @@ -226,6 +229,11 @@ return fVisible; } +void +BListItem::SetTop(float top) +{ + fTop = top; +} void BListItem::SetItemVisible(bool visible) Modified: haiku/trunk/src/kits/interface/ListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListView.cpp 2008-02-24 13:41:01 UTC (rev 24091) +++ haiku/trunk/src/kits/interface/ListView.cpp 2008-02-24 14:15:28 UTC (rev 24092) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2007, Haiku, Inc. + * Copyright (c) 2001-2008, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -7,6 +7,7 @@ * Marc Flerackers (mflerackers at androme.be) * Stephan Assmus * Axel D?rfler, axeld at pinc-software.de + * Rene Gollent (rene at gollent.com) */ @@ -102,8 +103,6 @@ fScrollView = NULL; fTrack = NULL; - fWidth = Bounds().Width(); - int32 i = 0; BMessage subData; @@ -464,7 +463,6 @@ void BListView::FrameResized(float width, float height) { - fWidth = Bounds().right; _FixupScrollBar(); } @@ -475,15 +473,13 @@ fScrollView = view; } - +// ScrollTo void BListView::ScrollTo(BPoint point) { BView::ScrollTo(point); - fWidth = Bounds().right; } - bool BListView::AddItem(BListItem *item, int32 index) { @@ -502,6 +498,8 @@ item->Update(this, &font); + _RecalcItemTops(index); + _FixupScrollBar(); _InvalidateFrom(index); } @@ -517,13 +515,15 @@ return false; // No need to adapt selection, as this item is the last in the list - + if (Window()) { BFont font; GetFont(&font); item->Update(this, &font); + _RecalcItemTops(CountItems() - 1); + _FixupScrollBar(); InvalidateItem(CountItems() - 1); } @@ -549,13 +549,12 @@ if (Window()) { BFont font; GetFont(&font); - - int32 i = 0; - while(BListItem *item = (BListItem*)list->ItemAt(i)) { - item->Update(this, &font); - i++; - } + for (int32 i = index; i <= (index + list->CountItems() - 1); i++) + ItemAt(i)->Update(this, &font); + + _RecalcItemTops(index); + _FixupScrollBar(); Invalidate(); // TODO } @@ -583,13 +582,15 @@ if (!fList.RemoveItem(item)) return NULL; - + if (fFirstSelected != -1 && index < fFirstSelected) fFirstSelected--; if (fLastSelected != -1 && index < fLastSelected) fLastSelected--; - + + _RecalcItemTops(index); + _InvalidateFrom(index); _FixupScrollBar(); @@ -700,16 +701,24 @@ int32 BListView::IndexOf(BPoint point) const { - float y = 0.0f; - - // TODO: somehow binary search, but items don't know their frame - for (int i = 0; i < fList.CountItems(); i++) { - y += ceilf(ItemAt(i)->Height()); - - if (point.y < y) - return i; - } - + int32 low = 0; + int32 high = fList.CountItems() - 1; + int32 mid = -1; + float frameTop = -1.0; + float frameBottom = 1.0; + // binary search the list + while (high >= low) { + mid = (low + high) / 2; + frameTop = ItemAt(mid)->Top(); + frameBottom = ItemAt(mid)->Bottom(); + if (point.y < frameTop) + high = mid - 1; + else if (point.y > frameBottom) + low = mid + 1; + else + return mid; + } + return -1; } @@ -955,6 +964,7 @@ } fList.SortItems(cmp); + _RecalcItemTops(0); Invalidate(); } @@ -1003,7 +1013,7 @@ if (!Messenger().IsValid()) SetTarget(Window(), NULL); - + _FixupScrollBar(); } @@ -1018,17 +1028,16 @@ BRect BListView::ItemFrame(int32 index) { - BRect frame(Bounds().left, 0, Bounds().right, -1); - - if (index < 0 || index >= CountItems()) - return frame; - - // TODO: this is very expensive, the (last) offsets could be cached - for (int32 i = 0; i <= index; i++) { - frame.top = frame.bottom + 1; - frame.bottom = frame.top + ceilf(ItemAt(i)->Height()) - 1; + BRect frame = Bounds(); + if (index < 0 || index >= CountItems()) { + frame.top = 0; + frame.bottom = -1; + } else { + BListItem* item = ItemAt(index); + frame.left = 0.0; + frame.top = item->Top(); + frame.bottom = item->Bottom(); } - return frame; } @@ -1104,7 +1113,21 @@ void BListView::GetPreferredSize(float *width, float *height) { - BView::GetPreferredSize(width, height); + int32 count = CountItems(); + + if (count > 0) { + float maxWidth = 0.0; + for (int32 i = 0; i < count; i++) { + float itemWidth = ItemAt(i)->Width(); + if (itemWidth > maxWidth) + maxWidth = itemWidth; + } + + *width = maxWidth; + *height = ItemAt(count - 1)->Bottom(); + } else { + BView::GetPreferredSize(width, height); + } } // AllAttached @@ -1187,7 +1210,6 @@ fFirstSelected = -1; fLastSelected = -1; fAnchorIndex = -1; - fWidth = Bounds().Width(); fSelectMessage = NULL; fScrollView = NULL; fTrack = new track_data; @@ -1206,10 +1228,11 @@ BRect bounds = Bounds(); int32 count = CountItems(); + + float itemHeight = 0.0; - float itemHeight = 0; - for (int32 i = 0; i < count; i++) - itemHeight += ceilf(ItemAt(i)->Height()); + if (CountItems() > 0) + itemHeight = ItemAt(CountItems() - 1)->Bottom(); if (bounds.Height() > itemHeight) { // no scrolling @@ -1254,10 +1277,10 @@ { BFont font; GetFont(&font); - - for (int i = 0; i < CountItems (); i ++) + for (int32 i = 0; i < CountItems(); i++) ItemAt(i)->Update(this, &font); -} + _RecalcItemTops(0); +} /*! @@ -1504,7 +1527,7 @@ fAnchorIndex = b; else if (fAnchorIndex == b) fAnchorIndex = a; - + // track selection // NOTE: this is only important if the selection status // of both items is not the same @@ -1525,6 +1548,8 @@ if (Window()) { // NOTE: window looper is assumed to be locked! if (aFrame.Height() != bFrame.Height()) { + ItemAt(a)->SetTop(bFrame.top); + ItemAt(b)->SetTop(aFrame.top); // items in between shifted visually Invalidate(aFrame | bFrame); } else { @@ -1558,7 +1583,9 @@ // same, the selection has still changed SelectionChanged(); } - + + _RecalcItemTops((to > from) ? from : to); + // take care of invalidation if (Window()) { // NOTE: window looper is assumed to be locked! @@ -1594,6 +1621,7 @@ _RescanSelection(start, end); SelectionChanged(); } + _RecalcItemTops(index); bool itemHeightChanged = frame != ItemFrame(index); @@ -1647,4 +1675,18 @@ } } +void +BListView::_RecalcItemTops(int32 start) +{ + int32 count = CountItems(); + if ((start < 0) || (start >= count)) + return; + float top = (start == 0) ? 0.0 : ItemAt(start - 1)->Bottom() + 1.0; + for (int32 i = start; i < CountItems(); i++) { + BListItem *item = ItemAt(i); + item->SetTop(top); + top += ceilf(item->Height()); + } +} + Modified: haiku/trunk/src/kits/interface/OutlineListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/OutlineListView.cpp 2008-02-24 13:41:01 UTC (rev 24091) +++ haiku/trunk/src/kits/interface/OutlineListView.cpp 2008-02-24 14:15:28 UTC (rev 24092) @@ -1,15 +1,17 @@ /* - * Copyright 2001-2007, Haiku Inc. + * Copyright 2001-2008, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: * Marc Flerackers (mflerackers at androme.be) * Axel D?rfler, axeld at pinc-software.de + * Rene Gollent (rene at gollent.com) */ //! BOutlineListView represents a "nestable" list view. #include +#include #include #include @@ -35,14 +37,14 @@ int32 right = last; do { - while (compareFunc(items[left], pivot) < 0) { + while ((compareFunc(items[left], pivot) < 0) && (left < last)) left++; - } - while (compareFunc(items[right], pivot) > 0) { + + while ((compareFunc(items[right], pivot) > 0) && (right > first)) right--; - } + - if (left <= right) { + if (left < right) { // swap entries BListItem* temp = items[left]; items[left] = items[right]; @@ -51,11 +53,14 @@ left++; right--; } - } while (left <= right); + } while (left < right); + // if our subset of the array consists of two elements, then we're done recursing + if (last - first <= 1) + return; + // At this point, the elements in the left half are all smaller // than the elements in the right half - if (first < right) { // sort left half quick_sort_item_array(items, first, right, compareFunc); @@ -181,7 +186,7 @@ { if (superitem == NULL) return AddItem(item); - + fFullList.AddItem(item, FullListIndexOf(superitem) + 1); item->fLevel = superitem->OutlineLevel() + 1; @@ -254,16 +259,20 @@ bool BOutlineListView::AddList(BList* newItems) { - printf("BOutlineListView::AddList Not implemented\n"); - return false; + return AddList(newItems, FullListCountItems()); } bool BOutlineListView::AddList(BList* newItems, int32 fullListIndex) { - printf("BOutlineListView::AddList Not implemented\n"); - return false; + if ((newItems == NULL) || (newItems->CountItems() == 0)) + return false; + + for (int32 i = 0; i < newItems->CountItems(); i++) + AddItem((BListItem *)newItems->ItemAt(i), fullListIndex + i); + + return true; } @@ -308,7 +317,12 @@ int32 BOutlineListView::FullListIndexOf(BPoint point) const { - return BListView::IndexOf(point); + int32 index = BListView::IndexOf(point); + + if (index > 0) + index = FullListIndex(index); + + return index; } @@ -386,7 +400,7 @@ BOutlineListView::FullListDoForEach(bool (*func)(BListItem* item, void* arg), void* arg) { - fList.DoForEach(reinterpret_cast(func), arg); + fFullList.DoForEach(reinterpret_cast(func), arg); } @@ -412,12 +426,12 @@ uint32 level = item->fLevel; int32 fullIndex = FullListIndexOf(item); int32 index = IndexOf(item) + 1; + int32 startIndex = index; int32 count = FullListCountItems() - fullIndex - 1; BListItem** items = (BListItem**)fFullList.Items() + fullIndex + 1; BFont font; GetFont(&font); - while (count-- > 0) { item = items[0]; if (item->fLevel <= level) @@ -445,7 +459,7 @@ } else items++; } - + _RecalcItemTops(startIndex); _FixupScrollBar(); Invalidate(); } @@ -462,6 +476,7 @@ uint32 level = item->fLevel; int32 fullIndex = FullListIndexOf(item); int32 index = IndexOf(item); + int32 startIndex = index; int32 max = FullListCountItems() - fullIndex - 1; int32 count = 0; BListItem** items = (BListItem**)fFullList.Items() + fullIndex + 1; @@ -482,7 +497,8 @@ items++; } - + + _RecalcItemTops(startIndex); // fix selection hints // TODO: revise for multi selection lists if (index < fFirstSelected) { @@ -496,7 +512,7 @@ Select(index); } } - + _FixupScrollBar(); Invalidate(); } @@ -615,8 +631,9 @@ } // only invalidate what may have changed + _RecalcItemTops(firstIndex); BRect top = ItemFrame(firstIndex); - BRect bottom = ItemFrame(lastIndex); + BRect bottom = ItemFrame(lastIndex - 1); BRect update(top.left, top.top, bottom.right, bottom.bottom); Invalidate(update); } @@ -798,6 +815,12 @@ bool BOutlineListView::DoMiscellaneous(MiscCode code, MiscData* data) { + if (code == B_SWAP_OP) { + // todo: If we do a swap and the items in question have children, we need + // to move the child hierarchy together with the item if we want to correctly + // mimic R5 behavior. + } + return BListView::DoMiscellaneous(code, data); } @@ -915,29 +938,24 @@ uint32 level = item->OutlineLevel(); int32 superIndex; BListItem* super = _SuperitemForIndex(fullIndex, level, &superIndex); - + if (item->IsItemVisible()) { // remove children, too - int32 max = FullListCountItems() - fullIndex - 1; - BListItem** items = (BListItem**)fFullList.Items() + fullIndex + 1; - - while (max-- > 0) { - BListItem* subItem = items[0]; - if (subItem->fLevel <= level) + while (fullIndex + 1 < CountItems()) { + BListItem *subItem = ItemAt(fullIndex + 1); + + if (subItem->OutlineLevel() <= level) break; if (subItem->IsItemVisible()) BListView::RemoveItem(subItem); - + fFullList.RemoveItem(fullIndex + 1); - - // TODO: this might be problematic, see comment above delete subItem; } - BListView::RemoveItem(item); } - + fFullList.RemoveItem(fullIndex); if (super != NULL) { @@ -946,7 +964,6 @@ if (child == NULL || child->OutlineLevel() <= super->OutlineLevel()) super->fHasSubitems = false; } - return item; } From stippi at mail.berlios.de Sun Feb 24 16:03:16 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 16:03:16 +0100 Subject: [Haiku-commits] r24093 - haiku/trunk/src/build/libhaikucompat Message-ID: <200802241503.m1OF3GX2025536@sheep.berlios.de> Author: stippi Date: 2008-02-24 16:03:15 +0100 (Sun, 24 Feb 2008) New Revision: 24093 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24093&view=rev Modified: haiku/trunk/src/build/libhaikucompat/misc.cpp Log: Export ktrace_printf for the test environment. Modified: haiku/trunk/src/build/libhaikucompat/misc.cpp =================================================================== --- haiku/trunk/src/build/libhaikucompat/misc.cpp 2008-02-24 14:15:28 UTC (rev 24092) +++ haiku/trunk/src/build/libhaikucompat/misc.cpp 2008-02-24 15:03:15 UTC (rev 24093) @@ -15,6 +15,12 @@ } +extern "C" void +ktrace_printf(const char *format, ...) +{ +} + + dev_t fs_mount_volume(const char *where, const char *device, const char *filesystem, uint32 flags, const char *parameters) @@ -28,3 +34,4 @@ { return B_ERROR; } + From jackburton at mail.berlios.de Sun Feb 24 16:29:10 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 24 Feb 2008 16:29:10 +0100 Subject: [Haiku-commits] r24094 - haiku/trunk/src/kits/interface Message-ID: <200802241529.m1OFTAML027170@sheep.berlios.de> Author: jackburton Date: 2008-02-24 16:29:10 +0100 (Sun, 24 Feb 2008) New Revision: 24094 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24094&view=rev Modified: haiku/trunk/src/kits/interface/MenuWindow.cpp Log: don't freak out if BMenuWindow::AttachScrollers() is called more than once (happens when a menu window has scrollers already, and we call BMenu::AddItem(). Modified: haiku/trunk/src/kits/interface/MenuWindow.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuWindow.cpp 2008-02-24 15:03:15 UTC (rev 24093) +++ haiku/trunk/src/kits/interface/MenuWindow.cpp 2008-02-24 15:29:10 UTC (rev 24094) @@ -280,22 +280,28 @@ void BMenuWindow::AttachScrollers() { - // We want to attach a scroller only if there's a menu frame already - // existing. + // We want to attach a scroller only if there's a + // menu frame already existing. if (!fMenu || !fMenuFrame) return; - - if (fUpperScroller || fLowerScroller) - debugger("Scrollers are already attached!"); - + fMenu->MakeFocus(true); BRect frame = Bounds(); - fUpperScroller = new UpperScroller(BRect(0, 0, frame.right, kScrollerHeight)); - AddChild(fUpperScroller); - fLowerScroller = new LowerScroller(BRect(0, frame.bottom - kScrollerHeight, frame.right, frame.bottom)); - AddChild(fLowerScroller); + if (fUpperScroller == NULL) { + fUpperScroller = new UpperScroller( + BRect(0, 0, frame.right, kScrollerHeight)); + AddChild(fUpperScroller); + } + + if (fLowerScroller == NULL) { + fLowerScroller = new LowerScroller( + BRect(0, frame.bottom - kScrollerHeight, + frame.right, frame.bottom)); + AddChild(fLowerScroller); + } + fUpperScroller->SetEnabled(false); fLowerScroller->SetEnabled(true); From stippi at mail.berlios.de Sun Feb 24 16:31:14 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 16:31:14 +0100 Subject: [Haiku-commits] r24095 - haiku/trunk/src/servers/app/drawing Message-ID: <200802241531.m1OFVEmr027343@sheep.berlios.de> Author: stippi Date: 2008-02-24 16:31:12 +0100 (Sun, 24 Feb 2008) New Revision: 24095 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24095&view=rev Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp haiku/trunk/src/servers/app/drawing/HWInterface.cpp haiku/trunk/src/servers/app/drawing/HWInterface.h Log: * ReadBitmap() could mess up the software cursor locking, since it used the BRect version of HideSoftwareCursor() but then called ShowSoftwareCursor() unconditionally. * Renamed Hide/ShowSoftwareCursor() to Hide/ShowFloatingOverlays(). * Removed no longer needed FontLocker. * Implemented AutoFloatingOverlaysHider and got rid of a lot of code duplication this way. Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2008-02-24 15:29:10 UTC (rev 24094) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2008-02-24 15:31:12 UTC (rev 24095) @@ -55,29 +55,35 @@ } -class FontLocker { +class AutoFloatingOverlaysHider { public: - FontLocker(const DrawState* context) - : - fFont(&context->Font()) + AutoFloatingOverlaysHider(HWInterface* interface, const BRect& area) + : fInterface(interface) + , fHidden(interface->HideFloatingOverlays(area)) { - fFont->Lock(); } - FontLocker(const ServerFont* font) - : - fFont(font) + AutoFloatingOverlaysHider(HWInterface* interface) + : fInterface(interface) + , fHidden(fInterface->HideFloatingOverlays()) { - fFont->Lock(); } - ~FontLocker() + ~AutoFloatingOverlaysHider() { - fFont->Unlock(); + if (fHidden) + fInterface->ShowFloatingOverlays(); } + bool WasHidden() const + { + return fHidden; + } + private: - const ServerFont* fFont; + HWInterface* fInterface; + bool fHidden; + }; @@ -395,8 +401,9 @@ BRect frame = region->Frame(); frame = frame | frame.OffsetByCopy(xOffset, yOffset); - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(frame); + AutoFloatingOverlaysHider _(fGraphicsCard, frame); + int32 count = region->CountRects(); // TODO: make this step unnecessary @@ -498,9 +505,6 @@ fGraphicsCard->CopyRegion(sortedRectList, count, xOffset, yOffset); delete[] sortedRectList; - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } // InvertRect @@ -512,7 +516,7 @@ make_rect_valid(r); r = fPainter->ClipRect(r); if (r.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); + AutoFloatingOverlaysHider _(fGraphicsCard, r); // try hardware optimized version first if (fAvailableHWAccleration & HW_ACC_INVERT_REGION) { @@ -524,9 +528,6 @@ fGraphicsCard->Invalidate(r); } - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -539,13 +540,11 @@ BRect clipped = fPainter->ClipRect(dest); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); fPainter->DrawBitmap(bitmap, source, dest); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -562,7 +561,7 @@ extend_by_stroke_width(clipped, fPainter->PenSize()); clipped = fPainter->ClipRect(r); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); float xRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0; @@ -575,8 +574,6 @@ fPainter->StrokeArc(center, xRadius, yRadius, angle, span); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -587,12 +584,12 @@ CRASH_IF_NOT_LOCKED // TODO: figure out bounds and hide cursor depending on that - fGraphicsCard->HideSoftwareCursor(); + fGraphicsCard->HideFloatingOverlays(); BRect touched = fPainter->DrawBezier(pts, filled); fGraphicsCard->Invalidate(touched); - fGraphicsCard->ShowSoftwareCursor(); + fGraphicsCard->ShowFloatingOverlays(); } // DrawEllipse @@ -616,13 +613,11 @@ clipped = fPainter->ClipRect(clipped); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); fPainter->DrawEllipse(r, filled); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -638,13 +633,11 @@ extend_by_stroke_width(bounds, fPainter->PenSize()); bounds = fPainter->ClipRect(bounds); if (bounds.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(bounds); + AutoFloatingOverlaysHider _(fGraphicsCard, bounds); fPainter->DrawPolygon(ptlist, numpts, filled, closed); fGraphicsCard->Invalidate(bounds); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -669,7 +662,7 @@ BRect touched(start, end); make_rect_valid(touched); touched = fPainter->ClipRect(touched); - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); + AutoFloatingOverlaysHider _(fGraphicsCard, touched); if (!fPainter->StraightLine(start, end, color)) { fPainter->SetHighColor(color); @@ -678,8 +671,6 @@ } fGraphicsCard->Invalidate(touched); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } // this function is used to draw a one pixel wide rect @@ -691,13 +682,11 @@ make_rect_valid(r); BRect clipped = fPainter->ClipRect(r); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); fPainter->StrokeRect(r, color); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -713,7 +702,7 @@ make_rect_valid(r); r = fPainter->ClipRect(r); if (r.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); + AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r); // try hardware optimized version first if (fAvailableHWAccleration & HW_ACC_FILL_REGION) { @@ -721,15 +710,12 @@ region.IntersectWith(fPainter->ClippingRegion()); fGraphicsCard->FillRegion(region, color, fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); } else { fPainter->FillRect(r, color); fGraphicsCard->Invalidate(r); } - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -755,13 +741,13 @@ return; } - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(frame); + AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, frame); // try hardware optimized version first if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0 && frame.Width() * frame.Height() > 100) { fGraphicsCard->FillRegion(r, color, fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); } else { int32 count = r.CountRects(); for (int32 i = 0; i < count; i++) { @@ -770,9 +756,6 @@ fGraphicsCard->Invalidate(frame); } - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } // #pragma mark - DrawState @@ -788,14 +771,11 @@ extend_by_stroke_width(clipped, fPainter->PenSize()); clipped = fPainter->ClipRect(clipped); if (clipped.IsValid()) { + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); - fPainter->StrokeRect(r); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -808,7 +788,7 @@ make_rect_valid(r); r = fPainter->AlignAndClipRect(r); if (r.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); + AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r); bool doInSoftware = true; if ((r.Width() + 1) * (r.Height() + 1) > 100.0) { @@ -822,7 +802,7 @@ region.IntersectWith(fPainter->ClippingRegion()); fGraphicsCard->FillRegion(region, fPainter->HighColor(), fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); doInSoftware = false; } else if (fPainter->Pattern() == B_SOLID_LOW && fPainter->DrawingMode() == B_OP_COPY) { @@ -830,7 +810,7 @@ region.IntersectWith(fPainter->ClippingRegion()); fGraphicsCard->FillRegion(region, fPainter->LowColor(), fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); doInSoftware = false; } } @@ -850,9 +830,6 @@ fGraphicsCard->Invalidate(r); } - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -864,7 +841,7 @@ BRect clipped = fPainter->ClipRect(r.Frame()); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped); bool doInSoftware = true; // try hardware optimized version first @@ -875,14 +852,14 @@ r.IntersectWith(fPainter->ClippingRegion()); fGraphicsCard->FillRegion(r, fPainter->HighColor(), fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); doInSoftware = false; } else if (fPainter->Pattern() == B_SOLID_LOW && fPainter->DrawingMode() == B_OP_COPY) { r.IntersectWith(fPainter->ClippingRegion()); fGraphicsCard->FillRegion(r, fPainter->LowColor(), fSuspendSyncLevel == 0 - || cursorTouched); + || overlaysHider.WasHidden()); doInSoftware = false; } } @@ -906,9 +883,6 @@ fGraphicsCard->Invalidate(touched); } - - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -929,14 +903,12 @@ clipped.bottom = ceilf(clipped.bottom); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); BRect touched = filled ? fPainter->FillRoundRect(r, xrad, yrad) : fPainter->StrokeRoundRect(r, xrad, yrad); fGraphicsCard->Invalidate(touched); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -949,14 +921,14 @@ // NOTE: hides cursor regardless of if and where // shape is drawn on screen, TODO: optimize - fGraphicsCard->HideSoftwareCursor(); + fGraphicsCard->HideFloatingOverlays(); BRect touched = fPainter->DrawShape(opCount, opList, ptCount, ptList, filled); fGraphicsCard->Invalidate(touched); - fGraphicsCard->ShowSoftwareCursor(); + fGraphicsCard->ShowFloatingOverlays(); } @@ -970,7 +942,7 @@ extend_by_stroke_width(clipped, fPainter->PenSize()); clipped = fPainter->ClipRect(clipped); if (clipped.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); + AutoFloatingOverlaysHider _(fGraphicsCard, clipped); if (filled) fPainter->FillTriangle(pts[0], pts[1], pts[2]); @@ -978,8 +950,6 @@ fPainter->StrokeTriangle(pts[0], pts[1], pts[2]); fGraphicsCard->Invalidate(clipped); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -994,13 +964,11 @@ extend_by_stroke_width(touched, fPainter->PenSize()); touched = fPainter->ClipRect(touched); if (touched.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); + AutoFloatingOverlaysHider _(fGraphicsCard, touched); fPainter->StrokeLine(start, end); fGraphicsCard->Invalidate(touched); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -1032,7 +1000,7 @@ extend_by_stroke_width(touched, fPainter->PenSize()); touched = fPainter->ClipRect(touched); if (touched.IsValid()) { - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); + AutoFloatingOverlaysHider _(fGraphicsCard, touched); data = (const LineArrayData *)&(linedata[0]); @@ -1056,8 +1024,6 @@ fPainter->SetPattern(pattern); fGraphicsCard->Invalidate(touched); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } } @@ -1088,7 +1054,7 @@ // TODO: BoundingBox is quite slow!! Optimizing it will be beneficial. // Cursiously, the DrawString after it is actually faster!?! // TODO: make the availability of the hardware cursor part of the -// HW acceleration flags and skip all calculations for HideSoftwareCursor +// HW acceleration flags and skip all calculations for HideFloatingOverlays // in case we don't have one. // TODO: Watch out about penLocation and use Painter::PenLocation() when // not using BoundindBox anymore. @@ -1098,7 +1064,7 @@ b = fPainter->ClipRect(b); if (b.IsValid()) { //printf("bounding box '%s': %lld ?s\n", string, system_time() - now); - bool cursorTouched = fGraphicsCard->HideSoftwareCursor(b); + AutoFloatingOverlaysHider _(fGraphicsCard, b); //now = system_time(); BRect touched = fPainter->DrawString(string, length, pt, delta, @@ -1106,8 +1072,6 @@ //printf("drawing string: %lld ?s\n", system_time() - now); fGraphicsCard->Invalidate(touched); - if (cursorTouched) - fGraphicsCard->ShowSoftwareCursor(); } return penLocation; @@ -1167,7 +1131,7 @@ BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1); bounds = bounds & clip; - fGraphicsCard->HideSoftwareCursor(bounds); + AutoFloatingOverlaysHider _(fGraphicsCard, bounds); status_t result = bitmap->ImportBits(buffer->Bits(), buffer->BitsLength(), buffer->BytesPerRow(), buffer->ColorSpace(), @@ -1209,8 +1173,6 @@ cursorWidth, cursorHeight); } - fGraphicsCard->ShowSoftwareCursor(); - return result; } Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-24 15:29:10 UTC (rev 24094) +++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-24 15:31:12 UTC (rev 24095) @@ -39,7 +39,7 @@ HWInterface::HWInterface(bool doubleBuffered) : MultiLocker("hw interface lock"), fCursorAreaBackup(NULL), - fSoftwareCursorLock("software cursor lock"), + fFloatingOverlaysLock("floating overlays lock"), fCursor(NULL), fDragBitmap(NULL), fDragBitmapOffset(0, 0), @@ -109,7 +109,7 @@ void HWInterface::SetCursor(ServerCursor* cursor) { - if (!fSoftwareCursorLock.Lock()) + if (!fFloatingOverlaysLock.Lock()) return; // TODO: if a bitmap is being dragged, it could @@ -145,14 +145,14 @@ _AdoptDragBitmap(fDragBitmap, fDragBitmapOffset); Invalidate(_CursorFrame()); } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } // SetCursorVisible void HWInterface::SetCursorVisible(bool visible) { - if (!fSoftwareCursorLock.Lock()) + if (!fFloatingOverlaysLock.Lock()) return; if (fCursorVisible != visible) { @@ -174,7 +174,7 @@ Invalidate(r); } } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } // IsCursorVisible @@ -182,9 +182,9 @@ HWInterface::IsCursorVisible() { bool visible = true; - if (fSoftwareCursorLock.Lock()) { + if (fFloatingOverlaysLock.Lock()) { visible = fCursorVisible; - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } return visible; } @@ -193,21 +193,21 @@ void HWInterface::ObscureCursor() { - if (!fSoftwareCursorLock.Lock()) + if (!fFloatingOverlaysLock.Lock()) return; if (!fCursorObscured) { SetCursorVisible(false); fCursorObscured = true; } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } // MoveCursorTo void HWInterface::MoveCursorTo(const float& x, const float& y) { - if (!fSoftwareCursorLock.Lock()) + if (!fFloatingOverlaysLock.Lock()) return; BPoint p(x, y); @@ -232,7 +232,7 @@ Invalidate(_CursorFrame()); } } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } @@ -240,9 +240,9 @@ HWInterface::CursorPosition() { BPoint location; - if (fSoftwareCursorLock.Lock()) { + if (fFloatingOverlaysLock.Lock()) { location = fCursorLocation; - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } return location; } @@ -252,9 +252,9 @@ HWInterface::SetDragBitmap(const ServerBitmap* bitmap, const BPoint& offsetFromCursor) { - if (fSoftwareCursorLock.Lock()) { + if (fFloatingOverlaysLock.Lock()) { _AdoptDragBitmap(bitmap, offsetFromCursor); - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } } @@ -403,9 +403,9 @@ bool -HWInterface::HideSoftwareCursor(const BRect& area) +HWInterface::HideFloatingOverlays(const BRect& area) { - if (!fSoftwareCursorLock.Lock()) + if (!fFloatingOverlaysLock.Lock()) return false; if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) { BRect backupArea(fCursorAreaBackup->left, @@ -418,26 +418,29 @@ return true; } } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); return false; } -void -HWInterface::HideSoftwareCursor() +bool +HWInterface::HideFloatingOverlays() { - fSoftwareCursorLock.Lock(); + if (!fFloatingOverlaysLock.Lock()) + return false; + _RestoreCursorArea(); + return true; } void -HWInterface::ShowSoftwareCursor() +HWInterface::ShowFloatingOverlays() { if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) { _DrawCursor(_CursorFrame()); } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } @@ -514,7 +517,7 @@ uint8* dst = buffer; if (fCursorAreaBackup && fCursorAreaBackup->buffer - && fSoftwareCursorLock.Lock()) { + && fFloatingOverlaysLock.Lock()) { fCursorAreaBackup->cursor_hidden = false; // remember which area the backup contains fCursorAreaBackup->left = left; @@ -550,7 +553,7 @@ dst += width * 4; bup += bupBPR; } - fSoftwareCursorLock.Unlock(); + fFloatingOverlaysLock.Unlock(); } else { // blending for (int32 y = top; y <= bottom; y++) { @@ -775,7 +778,8 @@ break; default: - fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front buffer format! (0x%lx)\n", frontBuffer->ColorSpace()); + fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front " + "buffer format! (0x%x)\n", frontBuffer->ColorSpace()); break; } } Modified: haiku/trunk/src/servers/app/drawing/HWInterface.h =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.h 2008-02-24 15:29:10 UTC (rev 24094) +++ haiku/trunk/src/servers/app/drawing/HWInterface.h 2008-02-24 15:31:12 UTC (rev 24095) @@ -159,9 +159,9 @@ // --- // NOTE: Investigate locking for these! The client code should already hold a // ReadLock, but maybe these functions should acquire a WriteLock! - bool HideSoftwareCursor(const BRect& area); - void HideSoftwareCursor(); - void ShowSoftwareCursor(); + bool HideFloatingOverlays(const BRect& area); + bool HideFloatingOverlays(); + void ShowFloatingOverlays(); // Listener support bool AddListener(HWInterfaceListener* listener); @@ -217,7 +217,7 @@ }; buffer_clip* fCursorAreaBackup; - mutable BLocker fSoftwareCursorLock; + mutable BLocker fFloatingOverlaysLock; ServerCursor* fCursor; const ServerBitmap* fDragBitmap; @@ -226,6 +226,9 @@ bool fCursorVisible; bool fCursorObscured; BPoint fCursorLocation; + + BRect fTrackingRect; + bool fDoubleBuffered; int fVGADevice; From jackburton at mail.berlios.de Sun Feb 24 16:51:39 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 24 Feb 2008 16:51:39 +0100 Subject: [Haiku-commits] r24096 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802241551.m1OFpdj5028551@sheep.berlios.de> Author: jackburton Date: 2008-02-24 16:51:39 +0100 (Sun, 24 Feb 2008) New Revision: 24096 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24096&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: Turns out #1804 was fixed, but I broke it again with a "cleanup" commit. Fixed for real. Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-24 15:31:12 UTC (rev 24095) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-24 15:51:39 UTC (rev 24096) @@ -101,7 +101,9 @@ sourceText < inText + length; sourceText += charLen) { charLen = UTF8NextCharLen(sourceText); - + + printf("charlen: %ld\n", charLen); + // End of string, bail out if (charLen <= 0) break; @@ -197,8 +199,7 @@ _BWidthBuffer_::InsertTable(const BFont *font) { _width_table_ table; - hashed_escapement *deltas = new hashed_escapement[kTableCount]; - + #if USE_DANO_WIDTHBUFFER table.font = *font; #else @@ -208,7 +209,7 @@ table.hashCount = 0; table.tableCount = kTableCount; - table.widths = deltas; + table.widths = new hashed_escapement[kTableCount]; uint32 position = fItemCount; InsertItemsAt(1, position, &table); @@ -295,6 +296,7 @@ // Insert the escapements into the hash table do { const int32 charLen = UTF8NextCharLen(text); + printf("charlen: %ld\n", charLen); if (charLen == 0) break; @@ -320,7 +322,6 @@ // the total size. if (table.tableCount * 2 / 3 <= table.hashCount) { const int32 newSize = table.tableCount * 2; - table.tableCount = newSize; // Create and initialize a new hash table hashed_escapement *newWidths = new hashed_escapement[newSize]; @@ -336,9 +337,10 @@ newWidths[newPos] = widths[oldPos]; } } - + // Delete the old table, and put the new pointer into the _width_table_ delete[] widths; + table.tableCount = newSize; table.widths = widths = newWidths; } } From jackburton at mail.berlios.de Sun Feb 24 17:00:44 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 24 Feb 2008 17:00:44 +0100 Subject: [Haiku-commits] r24097 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200802241600.m1OG0i9T029705@sheep.berlios.de> Author: jackburton Date: 2008-02-24 17:00:43 +0100 (Sun, 24 Feb 2008) New Revision: 24097 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24097&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp Log: and there, the usual forgotten debug stuff...\n Modified: haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-24 15:51:39 UTC (rev 24096) +++ haiku/trunk/src/kits/interface/textview_support/WidthBuffer.cpp 2008-02-24 16:00:43 UTC (rev 24097) @@ -102,8 +102,6 @@ sourceText += charLen) { charLen = UTF8NextCharLen(sourceText); - printf("charlen: %ld\n", charLen); - // End of string, bail out if (charLen <= 0) break; @@ -296,7 +294,6 @@ // Insert the escapements into the hash table do { const int32 charLen = UTF8NextCharLen(text); - printf("charlen: %ld\n", charLen); if (charLen == 0) break; From korli at users.berlios.de Sun Feb 24 17:12:58 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sun, 24 Feb 2008 17:12:58 +0100 Subject: [Haiku-commits] r24096 - haiku/trunk/src/kits/interface/textview_support In-Reply-To: <200802241551.m1OFpdj5028551@sheep.berlios.de> References: <200802241551.m1OFpdj5028551@sheep.berlios.de> Message-ID: <47C1978A.3070707@users.berlios.de> jackburton at BerliOS wrote: > + > + printf("charlen: %ld\n", charLen); > + > // End of string, bail out > if (charLen <= 0) > break; > > const int32 charLen = UTF8NextCharLen(text); > + printf("charlen: %ld\n", charLen); > if (charLen == 0) > break; > > > Hmmmm debug printfs :) Bye, J?r?me From stefano.ceccherini at gmail.com Sun Feb 24 17:07:43 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Sun, 24 Feb 2008 17:07:43 +0100 Subject: [Haiku-commits] r24096 - haiku/trunk/src/kits/interface/textview_support In-Reply-To: <47C1978A.3070707@users.berlios.de> References: <200802241551.m1OFpdj5028551@sheep.berlios.de> <47C1978A.3070707@users.berlios.de> Message-ID: <894b9700802240807p59d7374fi790e65019ea471aa@mail.gmail.com> 2008/2/24, J?r?me Duval : > jackburton at BerliOS wrote: > Hmmmm debug printfs :) > Yeah already noticed. Sorry :) From stippi at mail.berlios.de Sun Feb 24 17:08:57 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 17:08:57 +0100 Subject: [Haiku-commits] r24098 - haiku/trunk/src/servers/app/drawing Message-ID: <200802241608.m1OG8v7Q030257@sheep.berlios.de> Author: stippi Date: 2008-02-24 17:08:57 +0100 (Sun, 24 Feb 2008) New Revision: 24098 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24098&view=rev Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp Log: Use the AutoFloatingOverlaysHider in the remaining cases where overlays were hidden regardless of the affected area. Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2008-02-24 16:00:43 UTC (rev 24097) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2008-02-24 16:08:57 UTC (rev 24098) @@ -584,12 +584,11 @@ CRASH_IF_NOT_LOCKED // TODO: figure out bounds and hide cursor depending on that - fGraphicsCard->HideFloatingOverlays(); + AutoFloatingOverlaysHider _(fGraphicsCard); BRect touched = fPainter->DrawBezier(pts, filled); fGraphicsCard->Invalidate(touched); - fGraphicsCard->ShowFloatingOverlays(); } // DrawEllipse @@ -921,14 +920,13 @@ // NOTE: hides cursor regardless of if and where // shape is drawn on screen, TODO: optimize - fGraphicsCard->HideFloatingOverlays(); + AutoFloatingOverlaysHider _(fGraphicsCard); BRect touched = fPainter->DrawShape(opCount, opList, ptCount, ptList, filled); fGraphicsCard->Invalidate(touched); - fGraphicsCard->ShowFloatingOverlays(); } From stippi at mail.berlios.de Sun Feb 24 17:43:54 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 17:43:54 +0100 Subject: [Haiku-commits] r24099 - haiku/trunk/src/servers/app/drawing Message-ID: <200802241643.m1OGhsdF003459@sheep.berlios.de> Author: stippi Date: 2008-02-24 17:43:50 +0100 (Sun, 24 Feb 2008) New Revision: 24099 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24099&view=rev Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp haiku/trunk/src/servers/app/drawing/HWInterface.h Log: Cursor frame can be expressed using IntRect. Saves a few lines of code too. Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-24 16:08:57 UTC (rev 24098) +++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-02-24 16:43:50 UTC (rev 24099) @@ -162,12 +162,12 @@ if (visible) { fCursorVisible = visible; fCursorObscured = false; - BRect r = _CursorFrame(); + IntRect r = _CursorFrame(); _DrawCursor(r); Invalidate(r); } else { - BRect r = _CursorFrame(); + IntRect r = _CursorFrame(); fCursorVisible = visible; _RestoreCursorArea(); @@ -313,7 +313,7 @@ return B_NO_INIT; // we need to mess with the area, but it is const - BRect area(frame); + IntRect area(frame); BRect bufferClip(backBuffer->Bounds()); if (area.IsValid() && area.Intersects(bufferClip)) { @@ -471,13 +471,13 @@ // * area is where we potentially draw the cursor, the cursor // might be somewhere else, in which case this function does nothing void -HWInterface::_DrawCursor(BRect area) const +HWInterface::_DrawCursor(IntRect area) const { RenderingBuffer* backBuffer = DrawingBuffer(); if (!backBuffer || !area.IsValid()) return; - BRect cf = _CursorFrame(); + IntRect cf = _CursorFrame(); // make sure we don't copy out of bounds area = backBuffer->Bounds() & area; @@ -487,12 +487,8 @@ // clip to common area area = area & cf; - int32 left = (int32)area.left; - int32 top = (int32)area.top; - int32 right = (int32)area.right; - int32 bottom = (int32)area.bottom; - int32 width = right - left + 1; - int32 height = bottom - top + 1; + int32 width = area.right - area.left + 1; + int32 height = area.bottom - area.top + 1; // make a bitmap from the backbuffer // that has the cursor blended on top of it @@ -503,16 +499,16 @@ // offset into back buffer uint8* src = (uint8*)backBuffer->Bits(); uint32 srcBPR = backBuffer->BytesPerRow(); - src += top * srcBPR + left * 4; + src += area.top * srcBPR + area.left * 4; // offset into cursor bitmap uint8* crs = (uint8*)fCursorAndDragBitmap->Bits(); uint32 crsBPR = fCursorAndDragBitmap->BytesPerRow(); // since area is clipped to cf, - // the diff between top and cf.top is always positive, - // same for diff between left and cf.left - crs += (top - (int32)floorf(cf.top)) * crsBPR - + (left - (int32)floorf(cf.left)) * 4; + // the diff between area.top and cf.top is always positive, + // same for diff between area.left and cf.left + crs += (area.top - (int32)floorf(cf.top)) * crsBPR + + (area.left - (int32)floorf(cf.left)) * 4; uint8* dst = buffer; @@ -520,21 +516,21 @@ && fFloatingOverlaysLock.Lock()) { fCursorAreaBackup->cursor_hidden = false; // remember which area the backup contains - fCursorAreaBackup->left = left; - fCursorAreaBackup->top = top; - fCursorAreaBackup->right = right; - fCursorAreaBackup->bottom = bottom; + fCursorAreaBackup->left = area.left; + fCursorAreaBackup->top = area.top; + fCursorAreaBackup->right = area.right; + fCursorAreaBackup->bottom = area.bottom; uint8* bup = fCursorAreaBackup->buffer; uint32 bupBPR = fCursorAreaBackup->bpr; // blending and backup of drawing buffer - for (int32 y = top; y <= bottom; y++) { + for (int32 y = area.top; y <= area.bottom; y++) { uint8* s = src; uint8* c = crs; uint8* d = dst; uint8* b = bup; - for (int32 x = left; x <= right; x++) { + for (int32 x = area.left; x <= area.right; x++) { *(uint32*)b = *(uint32*)s; // assumes backbuffer alpha = 255 // assuming pre-multiplied cursor bitmap @@ -556,11 +552,11 @@ fFloatingOverlaysLock.Unlock(); } else { // blending - for (int32 y = top; y <= bottom; y++) { + for (int32 y = area.top; y <= area.bottom; y++) { uint8* s = src; uint8* c = crs; uint8* d = dst; - for (int32 x = left; x <= right; x++) { + for (int32 x = area.left; x <= area.right; x++) { // assumes backbuffer alpha = 255 // assuming pre-multiplied cursor bitmap uint8 a = 255 - c[3]; @@ -578,7 +574,8 @@ } } // copy result to front buffer - _CopyToFront(buffer, width * 4, left, top, right, bottom); + _CopyToFront(buffer, width * 4, area.left, area.top, area.right, + area.bottom); delete[] buffer; } @@ -786,10 +783,10 @@ // PRE: the object must be locked -BRect +IntRect HWInterface::_CursorFrame() const { - BRect frame(0.0, 0.0, -1.0, -1.0); + IntRect frame(0, 0, -1, -1); if (fCursorAndDragBitmap && fCursorVisible) { frame = fCursorAndDragBitmap->Bounds(); frame.OffsetTo(fCursorLocation - fCursorAndDragBitmap->GetHotSpot()); Modified: haiku/trunk/src/servers/app/drawing/HWInterface.h =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.h 2008-02-24 16:08:57 UTC (rev 24098) +++ haiku/trunk/src/servers/app/drawing/HWInterface.h 2008-02-24 16:43:50 UTC (rev 24099) @@ -20,7 +20,9 @@ #include #include +#include "IntRect.h" + class Overlay; class RenderingBuffer; class ServerBitmap; @@ -169,14 +171,14 @@ protected: // implement this in derived classes - virtual void _DrawCursor(BRect area) const; + virtual void _DrawCursor(IntRect area) const; // does the actual transfer and handles color space conversion void _CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y, int32 right, int32 bottom) const; - BRect _CursorFrame() const; + IntRect _CursorFrame() const; void _RestoreCursorArea() const; void _AdoptDragBitmap(const ServerBitmap* bitmap, const BPoint& offset); From stippi at mail.berlios.de Sun Feb 24 21:25:17 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 21:25:17 +0100 Subject: [Haiku-commits] r24100 - haiku/trunk/src/kits/interface Message-ID: <200802242025.m1OKPHTQ012623@sheep.berlios.de> Author: stippi Date: 2008-02-24 21:25:17 +0100 (Sun, 24 Feb 2008) New Revision: 24100 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24100&view=rev Modified: haiku/trunk/src/kits/interface/MenuField.cpp Log: Draw the label right at origin in B_ALIGN_LEFT mode. Should improve alignment with other controls. (BTextControl patch with the same change is upcomming, but it includes many other changes I didn't want to mix in.) Modified: haiku/trunk/src/kits/interface/MenuField.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuField.cpp 2008-02-24 16:43:50 UTC (rev 24099) +++ haiku/trunk/src/kits/interface/MenuField.cpp 2008-02-24 20:25:17 UTC (rev 24100) @@ -790,15 +790,15 @@ float x; switch (fAlign) { case B_ALIGN_RIGHT: - x = fDivider - fLayoutData->label_width - 3.0f; + x = fDivider - fLayoutData->label_width - 3.0; break; case B_ALIGN_CENTER: - x = fDivider - fLayoutData->label_width / 2.0f; + x = fDivider - fLayoutData->label_width / 2.0; break; default: - x = 3.0f; + x = 0.0; break; } From stippi at mail.berlios.de Sun Feb 24 21:39:32 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 21:39:32 +0100 Subject: [Haiku-commits] r24101 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200802242039.m1OKdWxa018491@sheep.berlios.de> Author: stippi Date: 2008-02-24 21:39:29 +0100 (Sun, 24 Feb 2008) New Revision: 24101 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24101&view=rev Modified: haiku/trunk/headers/os/interface/TextControl.h haiku/trunk/headers/os/interface/TextView.h haiku/trunk/src/kits/interface/TextControl.cpp haiku/trunk/src/kits/interface/TextInput.cpp haiku/trunk/src/kits/interface/TextInput.h haiku/trunk/src/kits/interface/TextView.cpp Log: BTextControl: * Placed _BTextInput_ into BPrivate namespace. * Made _BTextInput_::AlignTextRect() smarter, it centers the line vertically, for the case that the BTextControl has a larger label font. Improved insets for asthetics. * Used _BTextInput_::AlignTextRect() consistently in BTextControl, no more custom calls to SetTextRect(). Account for minimum vertical inset of 2 pixels in GetPreferredSize(). * Consistendly select all text when gaining focus in _BTextInput_. * Override MouseDown() in case the control did not have focus before, or else BTextView::MouseDown() will deselct the text again and place the cursor. (in line with BeOS behavior) * Removed unused fBool member from _BTextInput_ and other cleanup. BTextView: * Reimplemented BTextView::_AutoResize() so that it works well with BTextControl and autoscrolling when the alignment is not B_ALIGN_LEFT. I needed two new members for this, fLeftInset and fRightInset which are the original insets from the fTextRects. It might currently be broken for renaming things in Tracker, I will have to check. _AutoResize() no longer messes up the fTextRect insets. * Fixed stray carrets sometimes being left over, mostly when auto scrolling, but I observed them in other cases as well. * Prevent negative scrolling offsets when autoscrolling. Fixes weird scrolling offsets when navigating to the left. * Reset scrolling to B_ORIGIN when SetText() is called. Fixes for example starting to type in the middle of the control in Vision when entering new text and autoscrolling was triggered before. Modified: haiku/trunk/headers/os/interface/TextControl.h =================================================================== --- haiku/trunk/headers/os/interface/TextControl.h 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/headers/os/interface/TextControl.h 2008-02-24 20:39:29 UTC (rev 24101) @@ -10,9 +10,10 @@ #include class BLayoutItem; +namespace BPrivate { class _BTextInput_; +} - class BTextControl : public BControl { public: BTextControl(BRect frame, const char* name, @@ -105,7 +106,7 @@ void _UpdateFrame(); private: - _BTextInput_* fText; + BPrivate::_BTextInput_* fText; char* fLabel; BMessage* fModificationMessage; alignment fLabelAlign; Modified: haiku/trunk/headers/os/interface/TextView.h =================================================================== --- haiku/trunk/headers/os/interface/TextView.h 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/headers/os/interface/TextView.h 2008-02-24 20:39:29 UTC (rev 24101) @@ -315,6 +315,8 @@ _BLineBuffer_* fLines; _BStyleBuffer_* fStyles; BRect fTextRect; + float fLeftInset; + float fRightInset; int32 fSelStart; int32 fSelEnd; bool fCaretVisible; @@ -345,7 +347,7 @@ BPoint fWhere; _BTextTrackState_* fTrackingMouse; _BTextChangeResult_* fTextChange; - uint32 _reserved[9]; + uint32 _reserved[7]; static _BWidthBuffer_* sWidths; static sem_id sWidthSem; Modified: haiku/trunk/src/kits/interface/TextControl.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextControl.cpp 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/src/kits/interface/TextControl.cpp 2008-02-24 20:39:29 UTC (rev 24101) @@ -333,24 +333,26 @@ // label if (Label()) { - font_height fontHeight; - GetFontHeight(&fontHeight); + font_height fh; + GetFontHeight(&fh); - float y = fontHeight.ascent + fText->Frame().top + 1; + float y = Bounds().top + + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2 + + fh.ascent; float x; float labelWidth = StringWidth(Label()); switch (fLabelAlign) { case B_ALIGN_RIGHT: - x = fDivider - labelWidth - 3.0f; + x = fDivider - labelWidth - 3.0; break; case B_ALIGN_CENTER: - x = fDivider - labelWidth / 2.0f; + x = fDivider - labelWidth / 2.0; break; default: - x = 3.0f; + x = 0.0; break; } @@ -373,7 +375,6 @@ { if (!fText->IsFocus()) { fText->MakeFocus(true); - fText->SelectAll(); } } @@ -428,7 +429,7 @@ GetFontHeight(&fontHeight); float labelHeight = ceil(fontHeight.ascent + fontHeight.descent + fontHeight.leading); - float textHeight = ceilf(fText->LineHeight(0)) + 4.0; + float textHeight = ceilf(fText->LineHeight(0) + 1.0) + 4.0; *_height = max_c(labelHeight, textHeight); } @@ -730,7 +731,7 @@ } if (archive) - fText = static_cast<_BTextInput_ *>(FindView("_input_")); + fText = static_cast(FindView("_input_")); else { BRect frame(fDivider, bounds.top, bounds.right, bounds.bottom); @@ -739,7 +740,7 @@ frame.InsetBy(2.0, 3.0); BRect textRect(frame.OffsetToCopy(B_ORIGIN)); - fText = new _BTextInput_(frame, textRect, + fText = new BPrivate::_BTextInput_(frame, textRect, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS | navigableFlags); AddChild(fText); @@ -775,16 +776,7 @@ frame.InsetBy(2.0, 2.0); fText->MoveTo(frame.left, frame.top); fText->ResizeTo(frame.Width(), frame.Height()); - - BRect textRect(frame.OffsetToCopy(B_ORIGIN)); - - // the label font could require the control to be higher than - // necessary for the text view, we compensate this by layouting - // the text rect to be in the middle, normally this means there - // is one pixel spacing on each side - float lineHeight = ceilf(fText->LineHeight(0)); - textRect.InsetBy(1, floorf((frame.Height() - lineHeight) / 2)); - fText->SetTextRect(textRect); + fText->AlignTextRect(); } Modified: haiku/trunk/src/kits/interface/TextInput.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextInput.cpp 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/src/kits/interface/TextInput.cpp 2008-02-24 20:39:29 UTC (rev 24101) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku Inc. + * Copyright 2001-2008, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -20,20 +20,21 @@ #include "TextInput.h" +namespace BPrivate { + + _BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask, - uint32 flags) - : BTextView(frame, "_input_", textRect, resizeMask, flags), - fPreviousText(NULL), - fBool(false) + uint32 flags) + : BTextView(frame, "_input_", textRect, resizeMask, flags) + , fPreviousText(NULL) { MakeResizable(true); } -_BTextInput_::_BTextInput_(BMessage *archive) - : BTextView(archive), - fPreviousText(NULL), - fBool(false) +_BTextInput_::_BTextInput_(BMessage* archive) + : BTextView(archive) + , fPreviousText(NULL) { MakeResizable(true); } @@ -63,6 +64,19 @@ void +_BTextInput_::MouseDown(BPoint where) +{ + if (!IsFocus()) { + MakeFocus(true); + return; + } + + // only pass through to base class if we already have focus + BTextView::MouseDown(where); +} + + +void _BTextInput_::FrameResized(float width, float height) { BTextView::FrameResized(width, height); @@ -116,50 +130,39 @@ if (state) { SetInitialText(); - - fBool = true; - - if (Window()) { - BMessage *message = Window()->CurrentMessage(); - - if (message && message->what == B_KEY_DOWN) - SelectAll(); - } + SelectAll(); } else { if (strcmp(Text(), fPreviousText) != 0) TextControl()->Invoke(); free(fPreviousText); fPreviousText = NULL; - fBool = false; - - if (Window()) { - BMessage *message = Window()->CurrentMessage(); - - if (message && message->what == B_MOUSE_DOWN) - Select(0, 0); - } } - if (Window()) { +// if (Window()) { // TODO: why do we have to invalidate here? // I'm leaving this in, but it looks suspicious... :-) - Invalidate(Bounds()); +// Invalidate(Bounds()); if (BTextControl* parent = dynamic_cast(Parent())) { BRect frame = Frame(); frame.InsetBy(-1.0, -1.0); parent->Invalidate(frame); } - } +// } } void _BTextInput_::AlignTextRect() { - // TODO: just to get something working, it wouldn't be correct for - // scrolled views + // the label font could require the control to be higher than + // necessary for the text view, we compensate this by layouting + // the text rect to be in the middle, normally this means there + // is one pixel spacing on each side BRect textRect(Bounds()); + textRect.left = 0.0; + float vInset = max_c(1, floorf((textRect.Height() - LineHeight(0)) / 2.0)); + textRect.InsetBy(2, vInset); SetTextRect(textRect); } @@ -167,10 +170,8 @@ void _BTextInput_::SetInitialText() { - if (fPreviousText) { - free(fPreviousText); - fPreviousText = NULL; - } + free(fPreviousText); + fPreviousText = NULL; if (Text()) fPreviousText = strdup(Text()); @@ -237,3 +238,7 @@ return textControl; } + + +} // namespace BPrivate + Modified: haiku/trunk/src/kits/interface/TextInput.h =================================================================== --- haiku/trunk/src/kits/interface/TextInput.h 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/src/kits/interface/TextInput.h 2008-02-24 20:39:29 UTC (rev 24101) @@ -1,60 +1,35 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: TextInput.h -// Author: Frans van Nispen (xlr8 at tref.nl) -// Description: The BTextView derivative owned by an instance of -// BTextControl. -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2008, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Frans van Nispen (xlr8 at tref.nl) + */ +//! The BTextView derivative owned by an instance of BTextControl. + #ifndef _TEXT_CONTROLI_H #define _TEXT_CONTROLI_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - class BTextControl; -// _BTextInput_ class ---------------------------------------------------------- +namespace BPrivate { + class _BTextInput_ : public BTextView { public: _BTextInput_(BRect frame, BRect textRect, uint32 resizeMask, uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED); _BTextInput_(BMessage *data); - ~_BTextInput_(); +virtual ~_BTextInput_(); static BArchivable* Instantiate(BMessage *data); virtual status_t Archive(BMessage *data, bool deep = true) const; +virtual void MouseDown(BPoint where); virtual void FrameResized(float width, float height); virtual void KeyDown(const char *bytes, int32 numBytes); virtual void MakeFocus(bool focusState = true); @@ -78,14 +53,11 @@ char *fPreviousText; bool fBool; }; -//------------------------------------------------------------------------------ -#endif // _TEXT_CONTROLI_H +} // namespace BPrivate -/* - * $Log $ - * - * $Id $ - * - */ +using namespace BPrivate; + +#endif // _TEXT_CONTROLI_H + Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2008-02-24 20:25:17 UTC (rev 24100) +++ haiku/trunk/src/kits/interface/TextView.cpp 2008-02-24 20:39:29 UTC (rev 24101) @@ -400,8 +400,7 @@ fDragOffset = -1; fActive = false; - if (fResizable) - _AutoResize(true); + _AutoResize(true); _UpdateScrollbars(); @@ -995,7 +994,7 @@ // recalc line breaks and draw the text _Refresh(0, inLength, true, false); fClickOffset = fSelStart = fSelEnd = 0; - ScrollToOffset(fSelStart); + ScrollTo(B_ORIGIN); // draw the caret if (fActive) @@ -1917,13 +1916,16 @@ float lineHeight = 0.0; float xDiff = 0.0; float yDiff = 0.0; - BPoint point = PointAt(inOffset, &lineHeight); + BPoint point = PointAt(inOffset, &lineHeight); if (useHorizontal) { if (point.x < bounds.left) xDiff = point.x - bounds.left - bounds.IntegerWidth() / 2; else if (point.x >= bounds.right) xDiff = point.x - bounds.right + bounds.IntegerWidth() / 2; + // prevent negative scroll offset + if (bounds.left + xDiff < 0.0) + xDiff = -bounds.left; } if (useVertical) { @@ -1931,6 +1933,9 @@ yDiff = point.y - bounds.top - bounds.IntegerHeight() / 2; else if (point.y >= bounds.bottom) yDiff = point.y - bounds.bottom + bounds.IntegerHeight() / 2; + // prevent negative scroll offset + if (bounds.top + yDiff < 0.0) + yDiff = -bounds.top; } ScrollBy(xDiff, yDiff); @@ -1978,6 +1983,8 @@ return; fTextRect = rect; + fLeftInset = fTextRect.left; + fRightInset = Bounds().right - fTextRect.right; if (Window() != NULL) { Invalidate(); @@ -2708,6 +2715,8 @@ // to have less code duplication, and a single place where to do changes // if needed., fTextRect = textRect; + fLeftInset = fTextRect.left; + fRightInset = Bounds().right - fTextRect.right; fSelStart = fSelEnd = 0; fCaretVisible = false; fCaretTime = 0; @@ -3117,8 +3126,7 @@ || fAlignment != B_ALIGN_LEFT) drawOffset = (*fLines)[fromLine]->offset; - if (fResizable) - _AutoResize(false); + _AutoResize(false); _DrawLines(fromLine, toLine, drawOffset, erase); @@ -3541,7 +3549,7 @@ startLeft /= 2; startLeft += fTextRect.left; } - + view->MovePenTo(startLeft, line->origin + line->ascent + fTextRect.top + 1); if (erase) { @@ -3671,10 +3679,6 @@ if (fAlignment != B_ALIGN_LEFT) erase = true; - // Actually hide the caret - if (fCaretVisible) - _DrawCaret(fSelStart); - BRect eraseRect = clipRect; int32 startEraseLine = startLine; STELine* line = (*fLines)[startLine]; @@ -4097,32 +4101,31 @@ void BTextView::_AutoResize(bool redraw) { - if (fResizable) { - float oldWidth = Bounds().Width() + 1; - float newWidth = 3; - for (int32 i = 0; i < CountLines(); i++) - newWidth += LineWidth(i); - - BRect newRect(0, 0, ceilf(newWidth), ceilf(LineHeight(0)) + 2); - - if (fContainerView != NULL) { - fContainerView->ResizeTo(newRect.Width() + 1, newRect.Height()); - if (fAlignment == B_ALIGN_CENTER) - fContainerView->MoveBy(ceilf((oldWidth - (newRect.Width() + 1)) / 2), 0); - else if (fAlignment == B_ALIGN_RIGHT) - fContainerView->MoveBy(oldWidth - (newRect.Width() + 1), 0); - fContainerView->Invalidate(); - } - - fTextRect = newRect.InsetBySelf(0, 1); - - if (redraw) - _DrawLines(0, 0); - - // Erase the old text (TODO: Might not work for alignments different than B_ALIGN_LEFT) - SetLowColor(ViewColor()); - FillRect(BRect(fTextRect.right, fTextRect.top, Bounds().right, fTextRect.bottom), B_SOLID_LOW); + if (!fResizable) + return; + + BRect bounds = Bounds(); + float oldWidth = fTextRect.Width(); + float newWidth = max_c(bounds.Width() - (fLeftInset + fRightInset), + ceilf(LineWidth(0))); + + if (fContainerView != NULL) { + fContainerView->ResizeBy(ceilf(newWidth - oldWidth), 0); + if (fAlignment == B_ALIGN_CENTER) + fContainerView->MoveBy(ceilf((oldWidth - newWidth) / 2), 0); + else if (fAlignment == B_ALIGN_RIGHT) + fContainerView->MoveBy(ceilf(oldWidth - newWidth), 0); +// fContainerView->Invalidate(); } + + fTextRect.right = fTextRect.left + newWidth; + + if (redraw) + _DrawLines(0, 0); + + // Erase the old text (TODO: Might not work for alignments different than B_ALIGN_LEFT) + SetLowColor(ViewColor()); + FillRect(BRect(fTextRect.right, fTextRect.top, Bounds().right, fTextRect.bottom), B_SOLID_LOW); } From jackburton at mail.berlios.de Sun Feb 24 22:17:12 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 24 Feb 2008 22:17:12 +0100 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support Message-ID: <200802242117.m1OLHCnh025669@sheep.berlios.de> Author: jackburton Date: 2008-02-24 22:16:58 +0100 (Sun, 24 Feb 2008) New Revision: 24102 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24102&view=rev Modified: haiku/trunk/headers/os/support/String.h haiku/trunk/src/kits/support/String.cpp Log: Patch by Julun: implements a refcounted BString. Thank You! Modified: haiku/trunk/headers/os/support/String.h =================================================================== --- haiku/trunk/headers/os/support/String.h 2008-02-24 20:39:29 UTC (rev 24101) +++ haiku/trunk/headers/os/support/String.h 2008-02-24 21:16:58 UTC (rev 24102) @@ -1,7 +1,7 @@ /* - * Copyright 2001-2007, Haiku Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - */ +* Copyright 2001-2008, Haiku Inc. All Rights Reserved. +* Distributed under the terms of the MIT License. +*/ #ifndef __BSTRING__ #define __BSTRING__ @@ -11,252 +11,256 @@ #include -class BString { - public: - BString(); - BString(const char* string); - BString(const BString& string); - BString(const char* string, int32 maxLength); - ~BString(); +class BStringRef; - // Access - const char* String() const; - int32 Length() const; - // length of corresponding string - int32 CountChars() const; - // returns number of UTF8 characters in string +class BString +{ +public: + BString(); + BString(const char* string); + BString(const BString& string); + BString(const char* string, int32 maxLength); + ~BString(); - // Assignment - BString& operator=(const BString& string); - BString& operator=(const char* string); - BString& operator=(char c); + // Access + const char* String() const; + int32 Length() const; + int32 CountChars() const; + int32 ReferenceCount() const; - BString& SetTo(const char* string); - BString& SetTo(const char* string, int32 maxLength); + // Assignment + BString& operator=(const BString& string); + BString& operator=(const char* string); + BString& operator=(char c); - BString& SetTo(const BString& string); - BString& Adopt(BString& from); + BString& SetTo(const char* string); + BString& SetTo(const char* string, int32 maxLength); - BString& SetTo(const BString& string, int32 maxLength); - BString& Adopt(BString& from, int32 maxLength); + BString& SetTo(const BString& string); + BString& Adopt(BString& from); - BString& SetTo(char c, int32 count); + BString& SetTo(const BString& string, int32 maxLength); + BString& Adopt(BString& from, int32 maxLength); - // Substring copying - BString& CopyInto(BString& into, int32 fromOffset, - int32 length) const; - void CopyInto(char* into, int32 fromOffset, - int32 length) const; + BString& SetTo(char c, int32 count); - // Appending - BString& operator+=(const BString& string); - BString& operator+=(const char* string); - BString& operator+=(char c); + // Substring copying + BString& CopyInto(BString& into, int32 fromOffset, int32 length) const; + void CopyInto(char* into, int32 fromOffset, int32 length) const; - BString& Append(const BString& string); - BString& Append(const char* string); + // Appending + BString& operator+=(const BString& string); + BString& operator+=(const char* string); + BString& operator+=(char c); - BString& Append(const BString& string, int32 length); - BString& Append(const char* string, int32 length); - BString& Append(char c, int32 count); + BString& Append(const BString& string); + BString& Append(const char* string); - // Prepending - BString& Prepend(const char* string); - BString& Prepend(const BString& string); - BString& Prepend(const char* string, int32 length); - BString& Prepend(const BString& string, int32 length); - BString& Prepend(char c, int32 count); + BString& Append(const BString& string, int32 length); + BString& Append(const char* string, int32 length); + BString& Append(char c, int32 count); - // Inserting - BString& Insert(const char* string, int32 pos); - BString& Insert(const char* string, int32 length, int32 pos); - BString& Insert(const char* string, int32 fromOffset, - int32 length, int32 pos); + // Prepending + BString& Prepend(const char* string); + BString& Prepend(const BString& string); + BString& Prepend(const char* string, int32 length); + BString& Prepend(const BString& string, int32 length); + BString& Prepend(char c, int32 count); - BString& Insert(const BString& string, int32 pos); - BString& Insert(const BString& string, int32 length, int32 pos); - BString& Insert(const BString& string, int32 fromOffset, - int32 length, int32 pos); - BString& Insert(char, int32 count, int32 pos); + // Inserting + BString& Insert(const char* string, int32 position); + BString& Insert(const char* string, int32 length, int32 position); + BString& Insert(const char* string, int32 fromOffset, int32 length, + int32 position); + BString& Insert(const BString& string, int32 position); + BString& Insert(const BString& string, int32 length, int32 position); + BString& Insert(const BString& string, int32 fromOffset, int32 length, + int32 position); + BString& Insert(char c, int32 count, int32 position); - // Removing - BString& Truncate(int32 newLength, bool lazy = true); - BString& Remove(int32 from, int32 length); + // Removing + BString& Truncate(int32 newLength, bool lazy = true); + BString& Remove(int32 from, int32 length); - BString& RemoveFirst(const BString& string); - BString& RemoveLast(const BString& string); - BString& RemoveAll(const BString& string); + BString& RemoveFirst(const BString& string); + BString& RemoveLast(const BString& string); + BString& RemoveAll(const BString& string); - BString& RemoveFirst(const char* string); - BString& RemoveLast(const char* string); - BString& RemoveAll(const char* string); + BString& RemoveFirst(const char* string); + BString& RemoveLast(const char* string); + BString& RemoveAll(const char* string); - BString& RemoveSet(const char* setOfCharsToRemove); + BString& RemoveSet(const char* setOfCharsToRemove); - BString& MoveInto(BString& into, int32 from, int32 length); - void MoveInto(char* into, int32 from, int32 length); + BString& MoveInto(BString& into, int32 from, int32 length); + void MoveInto(char* into, int32 from, int32 length); - // Compare functions - bool operator<(const BString& string) const; - bool operator<=(const BString& string) const; - bool operator==(const BString& string) const; - bool operator>=(const BString& string) const; - bool operator>(const BString& string) const; - bool operator!=(const BString& string) const; + // Compare functions + bool operator<(const BString& string) const; + bool operator<=(const BString& string) const; + bool operator==(const BString& string) const; + bool operator>=(const BString& string) const; + bool operator>(const BString& string) const; + bool operator!=(const BString& string) const; - bool operator<(const char* string) const; - bool operator<=(const char* string) const; - bool operator==(const char* string) const; - bool operator>=(const char* string) const; - bool operator>(const char* string) const; - bool operator!=(const char* string) const; + bool operator<(const char* string) const; + bool operator<=(const char* string) const; + bool operator==(const char* string) const; + bool operator>=(const char* string) const; + bool operator>(const char* string) const; + bool operator!=(const char* string) const; - // strcmp()-style compare functions - int Compare(const BString& string) const; - int Compare(const char* string) const; - int Compare(const BString& string, int32 length) const; - int Compare(const char* string, int32 length) const; - int ICompare(const BString& string) const; - int ICompare(const char* string) const; - int ICompare(const BString& string, int32 length) const; - int ICompare(const char* string, int32 length) const; + // strcmp()-style compare functions + int Compare(const BString& string) const; + int Compare(const char* string) const; + int Compare(const BString& string, int32 length) const; + int Compare(const char* string, int32 length) const; + int ICompare(const BString& string) const; + int ICompare(const char* string) const; + int ICompare(const BString& string, int32 length) const; + int ICompare(const char* string, int32 length) const; - // Searching - int32 FindFirst(const BString& string) const; - int32 FindFirst(const char* string) const; - int32 FindFirst(const BString& string, int32 fromOffset) const; - int32 FindFirst(const char* string, int32 fromOffset) const; - int32 FindFirst(char c) const; - int32 FindFirst(char c, int32 fromOffset) const; + // Searching + int32 FindFirst(const BString& string) const; + int32 FindFirst(const char* string) const; + int32 FindFirst(const BString& string, int32 fromOffset) const; + int32 FindFirst(const char* string, int32 fromOffset) const; + int32 FindFirst(char c) const; + int32 FindFirst(char c, int32 fromOffset) const; - int32 FindLast(const BString& string) const; - int32 FindLast(const char* string) const; - int32 FindLast(const BString& string, int32 beforeOffset) const; - int32 FindLast(const char* string, int32 beforeOffset) const; - int32 FindLast(char c) const; - int32 FindLast(char c, int32 beforeOffset) const; + int32 FindLast(const BString& string) const; + int32 FindLast(const char* string) const; + int32 FindLast(const BString& string, int32 beforeOffset) const; + int32 FindLast(const char* string, int32 beforeOffset) const; + int32 FindLast(char c) const; + int32 FindLast(char c, int32 beforeOffset) const; - int32 IFindFirst(const BString& string) const; - int32 IFindFirst(const char* string) const; - int32 IFindFirst(const BString& string, int32 fromOffset) const; - int32 IFindFirst(const char* string, int32 fromOffset) const; + int32 IFindFirst(const BString& string) const; + int32 IFindFirst(const char* string) const; + int32 IFindFirst(const BString& string, int32 fromOffset) const; + int32 IFindFirst(const char* string, int32 fromOffset) const; - int32 IFindLast(const BString& string) const; - int32 IFindLast(const char* string) const; - int32 IFindLast(const BString& string, int32 beforeOffset) const; - int32 IFindLast(const char* string, int32 beforeOffset) const; + int32 IFindLast(const BString& string) const; + int32 IFindLast(const char* string) const; + int32 IFindLast(const BString& string, int32 beforeOffset) const; + int32 IFindLast(const char* string, int32 beforeOffset) const; - // Replacing - BString& ReplaceFirst(char replaceThis, char withThis); - BString& ReplaceLast(char replaceThis, char withThis); - BString& ReplaceAll(char replaceThis, char withThis, - int32 fromOffset = 0); - BString& Replace(char replaceThis, char withThis, - int32 maxReplaceCount, int32 fromOffset = 0); - BString& ReplaceFirst(const char* replaceThis, - const char* withThis); - BString& ReplaceLast(const char* replaceThis, - const char* withThis); - BString& ReplaceAll(const char* replaceThis, - const char* withThis, int32 fromOffset = 0); - BString& Replace(const char* replaceThis, const char* withThis, - int32 maxReplaceCount, int32 fromOffset = 0); + // Replacing + BString& ReplaceFirst(char replaceThis, char withThis); + BString& ReplaceLast(char replaceThis, char withThis); + BString& ReplaceAll(char replaceThis, char withThis, int32 fromOffset = 0); + BString& Replace(char replaceThis, char withThis, int32 maxReplaceCount, + int32 fromOffset = 0); + BString& ReplaceFirst(const char* replaceThis, const char* withThis); + BString& ReplaceLast(const char* replaceThis, const char* withThis); + BString& ReplaceAll(const char* replaceThis, const char* withThis, + int32 fromOffset = 0); + BString& Replace(const char* replaceThis, const char* withThis, + int32 maxReplaceCount, int32 fromOffset = 0); - BString& IReplaceFirst(char replaceThis, char withThis); - BString& IReplaceLast(char replaceThis, char withThis); - BString& IReplaceAll(char replaceThis, char withThis, - int32 fromOffset = 0); - BString& IReplace(char replaceThis, char withThis, - int32 maxReplaceCount, int32 fromOffset = 0); - BString& IReplaceFirst(const char* replaceThis, - const char* withThis); - BString& IReplaceLast(const char* replaceThis, - const char* withThis); - BString& IReplaceAll(const char* replaceThis, - const char* withThis, int32 fromOffset = 0); - BString& IReplace(const char* replaceThis, const char* withThis, - int32 maxReplaceCount, int32 fromOffset = 0); + BString& IReplaceFirst(char replaceThis, char withThis); + BString& IReplaceLast(char replaceThis, char withThis); + BString& IReplaceAll(char replaceThis, char withThis, int32 fromOffset = 0); + BString& IReplace(char replaceThis, char withThis, int32 maxReplaceCount, + int32 fromOffset = 0); + BString& IReplaceFirst(const char* replaceThis, const char* withThis); + BString& IReplaceLast(const char* replaceThis, const char* withThis); + BString& IReplaceAll(const char* replaceThis, const char* withThis, + int32 fromOffset = 0); + BString& IReplace(const char* replaceThis, const char* withThis, + int32 maxReplaceCount, int32 fromOffset = 0); - BString& ReplaceSet(const char* setOfChars, char with); - BString& ReplaceSet(const char* setOfChars, const char *with); + BString& ReplaceSet(const char* setOfChars, char with); + BString& ReplaceSet(const char* setOfChars, const char* with); - // Unchecked char access - char operator[](int32 index) const; - char& operator[](int32 index); + // Unchecked char access + char operator[](int32 index) const; - // Checked char access - char ByteAt(int32 index) const; +#if __GNUC__ > 3 + BStringRef operator[](int32 index); +#else + char& operator[](int32 index); +#endif - // Fast low-level manipulation - char* LockBuffer(int32 maxLength); - BString& UnlockBuffer(int32 length = -1); + // Checked char access + char ByteAt(int32 index) const; - // Upercase <-> Lowercase - BString& ToLower(); - BString& ToUpper(); + // Fast low-level manipulation + char* LockBuffer(int32 maxLength); + BString& UnlockBuffer(int32 length = -1); - BString& Capitalize(); - BString& CapitalizeEachWord(); + // Upercase <-> Lowercase + BString& ToLower(); + BString& ToUpper(); - // Escaping and De-escaping - BString& CharacterEscape(const char* original, - const char* setOfCharsToEscape, char escapeWith); - BString& CharacterEscape(const char* setOfCharsToEscape, - char escapeWith); + BString& Capitalize(); + BString& CapitalizeEachWord(); - BString& CharacterDeescape(const char* original, char escapeChar); - BString& CharacterDeescape(char escapeChar); + // Escaping and De-escaping + BString& CharacterEscape(const char* original, const char* setOfCharsToEscape, + char escapeWith); + BString& CharacterEscape(const char* setOfCharsToEscape, char escapeWith); + BString& CharacterDeescape(const char* original, char escapeChar); + BString& CharacterDeescape(char escapeChar); - // Slower than sprintf() but type and overflow safe - BString& operator<<(const char* string); - BString& operator<<(const BString& string); - BString& operator<<(char c); - BString& operator<<(int value); - BString& operator<<(unsigned int value); - BString& operator<<(uint32 value); - BString& operator<<(int32 value); - BString& operator<<(uint64 value); - BString& operator<<(int64 value); - BString& operator<<(float value); - // float output hardcodes %.2f style formatting + // Insert + BString& operator<<(const char* string); + BString& operator<<(const BString& string); + BString& operator<<(char c); + BString& operator<<(int value); + BString& operator<<(unsigned int value); + BString& operator<<(uint32 value); + BString& operator<<(int32 value); + BString& operator<<(uint64 value); + BString& operator<<(int64 value); + // float output hardcodes %.2f style formatting + BString& operator<<(float value); - private: - void _Init(const char *, int32); - void _DoAssign(const char *, int32); - void _DoAppend(const char *, int32); - char* _GrowBy(int32); - char* _OpenAtBy(int32, int32); - char* _ShrinkAtBy(int32, int32); - void _DoPrepend(const char *, int32); +private: + class PosVect; + friend class BStringRef; - int32 _FindAfter(const char *, int32, int32) const; - int32 _IFindAfter(const char *, int32, int32) const; - int32 _ShortFindAfter(const char *, int32) const; - int32 _FindBefore(const char *, int32, int32) const; - int32 _IFindBefore(const char *, int32, int32) const; - BString& _DoReplace(const char *, const char *, int32, int32, - bool); - void _SetLength(int32); + // Management + status_t _Detach(); + char* _Realloc(int32 length); + void _Init(const char* src, int32 length); + char* _Clone(const char* data, int32 length); + char* _OpenAtBy(int32 offset, int32 length); + char* _ShrinkAtBy(int32 offset, int32 length); + status_t _DetachWith(const char* string, int32 length); -#if DEBUG - void _SetUsingAsCString(bool); - void _AssertNotUsingAsCString() const; -#else - void _SetUsingAsCString(bool) {} - void _AssertNotUsingAsCString() const {} -#endif + // Data + void _SetLength(int32 length); + void _SetReferenceCount(int32 count); + bool _DoAppend(const char* string, int32 length); + bool _DoPrepend(const char* string, int32 length); + bool _DoInsert(const char* string, int32 offset, int32 length); - char* _Alloc(int32 size); + // Search + int32 _ShortFindAfter(const char* string, int32 len) const; + int32 _FindAfter(const char* string, int32 offset, int32 strlen) const; + int32 _IFindAfter(const char* string, int32 offset, int32 strlen) const; - class PosVect; - void _ReplaceAtPositions(const PosVect* positions, - int32 searchLength, const char* with, int32 withLen); + int32 _FindBefore(const char* string, int32 offset, int32 strlen) const; + int32 _IFindBefore(const char* string, int32 offset, int32 strlen) const; - protected: - char* fPrivateData; + // Escape + BString& _DoCharacterEscape(const char* string, + const char *setOfCharsToEscape, char escapeChar); + BString& _DoCharacterDeescape(const char* string, char escapeChar); + + // Replace + BString& _DoReplace(const char* findThis, const char* replaceWith, + int32 maxReplaceCount, int32 fromOffset, bool ignoreCase); + void _ReplaceAtPositions(const PosVect* positions, int32 searchLen, + const char* with, int32 withLen); + +private: + char* fPrivateData; }; + // Commutative compare operators bool operator<(const char* a, const BString& b); bool operator<=(const char* a, const BString& b); @@ -265,6 +269,7 @@ bool operator>=(const char* a, const BString& b); bool operator!=(const char* a, const BString& b); + // Non-member compare for sorting, etc. int Compare(const BString& a, const BString& b); int ICompare(const BString& a, const BString& b); @@ -272,16 +277,16 @@ int ICompare(const BString* a, const BString* b); -inline int32 +inline int32 BString::Length() const { - return fPrivateData ? (*((int32 *)fPrivateData - 1) & 0x7fffffff) : 0; - /* the most significant bit is reserved; accessing - * it in any way will cause the computer to explode - */ + // the most significant bit is reserved; accessing + // it in any way will cause the computer to explode + return fPrivateData ? (*(((int32 *)fPrivateData) - 1) & 0x7fffffff) : 0; } -inline const char * + +inline const char* BString::String() const { if (!fPrivateData) @@ -289,19 +294,29 @@ return fPrivateData; } + +inline int32 +BString::ReferenceCount() const +{ + return fPrivateData ? (*(((int32 *)fPrivateData) - 2)) : 1; +} + + inline BString & -BString::SetTo(const char *string) +BString::SetTo(const char* string) { return operator=(string); } -inline char + +inline char BString::operator[](int32 index) const { return fPrivateData[index]; } -inline char + +inline char BString::ByteAt(int32 index) const { if (!fPrivateData || index < 0 || index > Length()) @@ -309,6 +324,7 @@ return fPrivateData[index]; } + inline BString & BString::operator+=(const BString &string) { @@ -316,6 +332,7 @@ return *this; } + inline BString & BString::Append(const BString &string) { @@ -323,88 +340,125 @@ return *this; } + inline BString & -BString::Append(const char *str) +BString::Append(const char* string) { - return operator+=(str); + return operator+=(string); } -inline bool + +inline bool BString::operator==(const BString &string) const { return strcmp(String(), string.String()) == 0; } -inline bool + +inline bool BString::operator<(const BString &string) const { return strcmp(String(), string.String()) < 0; } -inline bool + +inline bool BString::operator<=(const BString &string) const { return strcmp(String(), string.String()) <= 0; } -inline bool + +inline bool BString::operator>=(const BString &string) const { return strcmp(String(), string.String()) >= 0; } -inline bool + +inline bool BString::operator>(const BString &string) const { return strcmp(String(), string.String()) > 0; } -inline bool + +inline bool BString::operator!=(const BString &string) const { return strcmp(String(), string.String()) != 0; } -inline bool -BString::operator!=(const char *str) const + +inline bool +BString::operator!=(const char* string) const { - return !operator==(str); + return !operator==(string); } -inline bool + +inline bool operator<(const char *str, const BString &string) { return string > str; } -inline bool + +inline bool operator<=(const char *str, const BString &string) { return string >= str; } -inline bool + +inline bool operator==(const char *str, const BString &string) { return string == str; } -inline bool + +inline bool operator>(const char *str, const BString &string) { return string < str; } -inline bool + +inline bool operator>=(const char *str, const BString &string) { return string <= str; } -inline bool + +inline bool operator!=(const char *str, const BString &string) { return string != str; } -#endif /* __BSTRING__ */ + +// #pragma mark - BStringRef + + +class BStringRef +{ +public: + BStringRef(BString& string, int32 position); + ~BStringRef() {} + + operator char() const; + + char* operator&(); + const char* operator&() const; + + BStringRef& operator=(char c); + BStringRef &operator=(const BStringRef &rc); + +private: + BString& fString; + int32 fPosition; +}; + +#endif // __BSTRING__ Modified: haiku/trunk/src/kits/support/String.cpp =================================================================== --- haiku/trunk/src/kits/support/String.cpp 2008-02-24 20:39:29 UTC (rev 24101) +++ haiku/trunk/src/kits/support/String.cpp 2008-02-24 21:16:58 UTC (rev 24102) @@ -1,13 +1,14 @@ /* - * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Marc Flerackers (mflerackers at androme.be) - * Stefano Ceccherini (burton666 at libero.it) - * Oliver Tappe (openbeos at hirschkaefer.de) - * Axel D??rfler, axeld at pinc-software.de - */ +* Copyright 2001-2008, Haiku, Inc. All Rights Reserved. +* Distributed under the terms of the MIT License. +* +* Authors: +* Marc Flerackers (mflerackers at androme.be) +* Stefano Ceccherini (burton666 at libero.it) +* Oliver Tappe (openbeos at hirschkaefer.de) +* Axel D?rfler, axeld at pinc-software.de +* Julun +*/ /* String class supporting common string operations. */ @@ -31,59 +32,13 @@ #define REPLACE_ALL 0x7FFFFFFF -// helper macro that is used to fall into debugger if a given param check fails: -#ifdef DEBUG - #define CHECK_PARAM( expr, msg) \ - if (!(expr)) \ - debugger( msg) - - #define CHECK_PARAM_RET( expr, msg, retval) \ - if (!(expr)) \ - debugger( msg) - - #define CHECK_PARAM_VOID( expr, msg) \ - if (!(expr)) \ - debugger( msg) -#else - #define CHECK_PARAM( expr, msg) \ - if (!(expr)) \ - return *this - - #define CHECK_PARAM_RET( expr, msg, retval) \ - if (!(expr)) \ - return (retval); - - #define CHECK_PARAM_VOID( expr, msg) -#endif - - -//! helper class for BString::_ReplaceAtPositions(): -class BString::PosVect { - public: - PosVect(); - ~PosVect(); - - bool Add(int32 pos); - - inline int32 ItemAt(int32 index) const - { return fBuffer[index]; } - inline int32 CountItems() const - { return fSize; } - - private: - int32 fSize; - int32 fBufferSize; - int32* fBuffer; -}; - - const char *B_EMPTY_STRING = ""; // helper function, returns minimum of two given values (but clamps to 0): static inline int32 -min_clamp0(int32 num1, int32 num2) -{ +min_clamp0(int32 num1, int32 num2) +{ if (num1 < num2) return num1 > 0 ? num1 : 0; @@ -93,7 +48,7 @@ //! helper function, returns length of given string (but clamps to given maximum): static inline int32 -strlen_clamp(const char* str, int32 max) +strlen_clamp(const char* str, int32 max) { // this should yield 0 for max<0: int32 length = 0; @@ -105,92 +60,151 @@ //! helper function, massages given pointer into a legal c-string: -static inline const char * -safestr(const char* str) +static inline const char * +safestr(const char* str) { return str ? str : ""; } -// #pragma mark - +// #pragma mark - PosVect -BString::PosVect::PosVect() - : - fSize(0), - fBufferSize(20), - fBuffer(NULL) +class BString::PosVect { +public: + PosVect() + : fSize(0), + fBufferSize(20), + fBuffer(NULL) { } + + ~PosVect() + { + free(fBuffer); + } + + bool Add(int32 pos) + { + if (fBuffer == NULL || fSize == fBufferSize) { + if (fBuffer != NULL) + fBufferSize *= 2; + + int32* newBuffer = NULL; + newBuffer = (int32 *)realloc(fBuffer, fBufferSize * sizeof(int32)); + if (newBuffer == NULL) + return false; + + fBuffer = newBuffer; + } + + fBuffer[fSize++] = pos; + return true; + } + + inline int32 ItemAt(int32 index) const + { return fBuffer[index]; } + inline int32 CountItems() const + { return fSize; } + +private: + int32 fSize; + int32 fBufferSize; + int32* fBuffer; +}; + + +// #pragma mark - BStringRef + + +BStringRef::BStringRef(BString& string, int32 position) + : fString(string), fPosition(position) { } -BString::PosVect::~PosVect() +BStringRef::operator char() const { - free(fBuffer); + return fPosition < fString.Length() ? fString.fPrivateData[fPosition] : 0; } -bool -BString::PosVect::Add(int32 pos) +BStringRef& +BStringRef::operator=(char c) { - if (fBuffer == NULL || fSize == fBufferSize) { - if (fBuffer != NULL) - fBufferSize *= 2; + fString._Detach(); + fString.fPrivateData[fPosition] = c; + return *this; +} - int32* newBuffer = (int32 *)realloc(fBuffer, fBufferSize * sizeof(int32)); - if (newBuffer == NULL) - return false; - fBuffer = newBuffer; - } +BStringRef& +BStringRef::operator=(const BStringRef &rc) +{ + return operator=(rc.fString.fPrivateData[rc.fPosition]); +} - fBuffer[fSize++] = pos; - return true; + +const char* +BStringRef::operator&() const +{ + return &(fString.fPrivateData[fPosition]); } +char* +BStringRef::operator&() +{ + fString._Detach(); + fString._SetReferenceCount(-1); + return &(fString.fPrivateData[fPosition]); +} + + // #pragma mark - BString BString::BString() - : fPrivateData(NULL) + : fPrivateData(NULL) { + _Init("", 0); } BString::BString(const char* string) : fPrivateData(NULL) { - if (string != NULL) - _Init(string, strlen(string)); + _Init(string, strlen(safestr(string))); } -BString::BString(const BString &string) - : fPrivateData(NULL) +BString::BString(const BString& string) + : fPrivateData(NULL) { - _Init(string.String(), string.Length()); + // check if source is sharable - if so, share else clone + if (atomic_get(&(*(((vint32*)string.fPrivateData) - 2))) >= 0) { + fPrivateData = string.fPrivateData; + atomic_add(&(*(((vint32*)fPrivateData) - 2)), 1); + } else + fPrivateData = _Clone(string.fPrivateData, string.Length()); } -BString::BString(const char *string, int32 maxLength) - : fPrivateData(NULL) +BString::BString(const char* string, int32 maxLength) + : fPrivateData(NULL) { - if (string != NULL) - _Init(string, strlen_clamp(string, maxLength)); + _Init(string, strlen_clamp(safestr(string), maxLength)); } BString::~BString() { - if (fPrivateData) - free(fPrivateData - sizeof(int32)); + if (atomic_add(&(*(((vint32*)fPrivateData) - 2)), -1) < 1) + free(fPrivateData - (2 * sizeof(int32))); } // #pragma mark - Access - + int32 BString::CountChars() const { @@ -214,22 +228,17 @@ BString& -BString::operator=(const BString &string) +BString::operator=(const BString& string) { - if (&string != this) // Avoid auto-assignment - _DoAssign(string.String(), string.Length()); - return *this; + return SetTo(string); } BString& -BString::operator=(const char *str) [... truncated: 2289 lines follow ...] From anevilyak at gmail.com Sun Feb 24 22:31:18 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 24 Feb 2008 15:31:18 -0600 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support In-Reply-To: <200802242117.m1OLHCnh025669@sheep.berlios.de> References: <200802242117.m1OLHCnh025669@sheep.berlios.de> Message-ID: > Patch by Julun: implements a refcounted BString. Thank You! I'm curious, in what circumstances does the refcount come into play? Is it only if a string is duplicated via the copy c'tor? Or will something like this: BString a = "This is a test"; BString b = "This is a test"; Also result in two BStrings referring to the same data? Regards, Rene From axeld at pinc-software.de Sun Feb 24 22:47:03 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 24 Feb 2008 22:47:03 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r24101_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/os/interface_src/kits/interface?= In-Reply-To: <200802242039.m1OKdWxa018491@sheep.berlios.de> Message-ID: <2534106178-BeMail@zon> stippi at BerliOS wrote: > - font_height fontHeight; > - GetFontHeight(&fontHeight); > + font_height fh; > + GetFontHeight(&fh); We actually advertize the use of sensible variable names, so there is probably no need for this kind of changes. The rest is fine, though ;-) Bye, Axel. From axeld at pinc-software.de Sun Feb 24 22:53:34 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 24 Feb 2008 22:53:34 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r24086_-_in_haiku/trunk/src/bin/t?= =?iso-8859-15?q?ar=3A_=2E_lib_lib/uniwidth_rmt_src?= In-Reply-To: <200802232238.m1NMcK6k023129@sheep.berlios.de> Message-ID: <2925934647-BeMail@zon> korli at BerliOS wrote: > Log: > updated tar to 1.19 - was harder than expected. Any particular problems that you faced? Bye, Axel. From axeld at pinc-software.de Sun Feb 24 22:55:46 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 24 Feb 2008 22:55:46 +0100 CET Subject: [Haiku-commits] r24084 - haiku/trunk/src/servers/app/drawing In-Reply-To: <200802231939.m1NJdhne030645@sheep.berlios.de> Message-ID: <3058018421-BeMail@zon> stippi at BerliOS wrote: > Log: > * Always use the double buffered implementation if running in VESA > mode. It > was not used in case of 32 bit VESA modes. Gives a huge performance > boost > for 32 bit VESA mode. Doesn't that tell us that we don't draw that efficiently? Or does double buffering allow more than one drawing operation until the frame buffer is updated? After all, we do enable write combining for VESA if possible. Bye, Axel. From axeld at pinc-software.de Sun Feb 24 23:06:19 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 24 Feb 2008 23:06:19 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r24102_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/os/support_src/kits/support?= In-Reply-To: <200802242117.m1OLHCnh025669@sheep.berlios.de> Message-ID: <3690565208-BeMail@zon> jackburton at BerliOS wrote: > -class BString { [...] > +class BString > +{ Nice, but is there any reason to violate our coding style here? :-) Bye, Axel. From superstippi at gmx.de Sun Feb 24 23:20:50 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 24 Feb 2008 23:20:50 +0100 Subject: [Haiku-commits] r24084 - haiku/trunk/src/servers/app/drawing In-Reply-To: <3058018421-BeMail@zon> References: <3058018421-BeMail@zon> Message-ID: <20080224232050.11749.1@stippis2.1203879296.fake> On 2008-02-24 at 22:55:46 [+0100], Axel D?rfler wrote: > stippi at BerliOS wrote: > > Log: > > * Always use the double buffered implementation if running in VESA > > mode. It > > was not used in case of 32 bit VESA modes. Gives a huge performance > > boost > > for 32 bit VESA mode. > > Doesn't that tell us that we don't draw that efficiently? Or does double > buffering allow more than one drawing operation until the frame buffer is > updated? > After all, we do enable write combining for VESA if possible. The problem is reading the frame buffer, which you have to do for stuff like CopyBits(), scrolling in views or moving windows. When writing to the screen only, the difference is not big I guess. Best regards, -Stephan From julun at mail.berlios.de Sun Feb 24 23:22:43 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Sun, 24 Feb 2008 23:22:43 +0100 Subject: [Haiku-commits] r24103 - haiku/trunk/headers/os/support Message-ID: <200802242222.m1OMMhre002924@sheep.berlios.de> Author: julun Date: 2008-02-24 23:22:43 +0100 (Sun, 24 Feb 2008) New Revision: 24103 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24103&view=rev Modified: haiku/trunk/headers/os/support/String.h Log: * fixed coding style... Modified: haiku/trunk/headers/os/support/String.h =================================================================== --- haiku/trunk/headers/os/support/String.h 2008-02-24 21:16:58 UTC (rev 24102) +++ haiku/trunk/headers/os/support/String.h 2008-02-24 22:22:43 UTC (rev 24103) @@ -14,8 +14,7 @@ class BStringRef; -class BString -{ +class BString { public: BString(); BString(const char* string); From superstippi at gmx.de Sun Feb 24 23:33:16 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 24 Feb 2008 23:33:16 +0100 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support In-Reply-To: References: <200802242117.m1OLHCnh025669@sheep.berlios.de> Message-ID: <20080224233316.11830.2@stippis2.1203879296.fake> On 2008-02-24 at 22:31:18 [+0100], Rene Gollent wrote: > > Patch by Julun: implements a refcounted BString. Thank You! > > > I'm curious, in what circumstances does the refcount come into play? Is > it only if a string is duplicated via the copy c'tor? Or will something > like this: > > BString a = "This is a test"; > BString b = "This is a test"; > > Also result in two BStrings referring to the same data? I would hope this were two separate BStrings, because I want the lower memory footprint and faster operations, like assignement, but not added overhead to check for duplicate strings. If you happen to know you are storing the same strings over and over, you could copy them from a global instance and benefit from the ref counting. Best regards, -Stephan From julun at mail.berlios.de Sun Feb 24 23:33:46 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Sun, 24 Feb 2008 23:33:46 +0100 Subject: [Haiku-commits] r24104 - haiku/trunk/src/tests/kits/support/bstring Message-ID: <200802242233.m1OMXk6D004680@sheep.berlios.de> Author: julun Date: 2008-02-24 23:33:46 +0100 (Sun, 24 Feb 2008) New Revision: 24104 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24104&view=rev Modified: haiku/trunk/src/tests/kits/support/bstring/StringAssignTest.cpp Log: * fixed Adopt(BString, len) test, as after adopt the source string should be empty, thus the pointer into that string should point to empty data... Modified: haiku/trunk/src/tests/kits/support/bstring/StringAssignTest.cpp =================================================================== --- haiku/trunk/src/tests/kits/support/bstring/StringAssignTest.cpp 2008-02-24 22:22:43 UTC (rev 24103) +++ haiku/trunk/src/tests/kits/support/bstring/StringAssignTest.cpp 2008-02-24 22:33:46 UTC (rev 24104) @@ -95,7 +95,7 @@ const char *oldString = newstring.String(); str = new BString; str->Adopt(newstring, 2); - CPPUNIT_ASSERT(strncmp(str->String(), oldString, 2) == 0); + CPPUNIT_ASSERT(strncmp(str->String(), "SomethingElseAgain", 2) == 0); CPPUNIT_ASSERT(str->Length() == 2); CPPUNIT_ASSERT(strcmp(newstring.String(), "") == 0); delete str; From stippi at mail.berlios.de Sun Feb 24 23:35:31 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 24 Feb 2008 23:35:31 +0100 Subject: [Haiku-commits] r24105 - haiku/trunk/src/kits/interface Message-ID: <200802242235.m1OMZVqF004815@sheep.berlios.de> Author: stippi Date: 2008-02-24 23:35:30 +0100 (Sun, 24 Feb 2008) New Revision: 24105 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24105&view=rev Modified: haiku/trunk/src/kits/interface/TextControl.cpp Log: fh -> fontHeight Modified: haiku/trunk/src/kits/interface/TextControl.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextControl.cpp 2008-02-24 22:33:46 UTC (rev 24104) +++ haiku/trunk/src/kits/interface/TextControl.cpp 2008-02-24 22:35:30 UTC (rev 24105) @@ -333,12 +333,11 @@ // label if (Label()) { - font_height fh; - GetFontHeight(&fh); + font_height fontHeight; + GetFontHeight(&fontHeight); - float y = Bounds().top - + (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2 - + fh.ascent; + float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent + - fontHeight.descent) / 2 + fontHeight.ascent; float x; float labelWidth = StringWidth(Label()); From anevilyak at gmail.com Sun Feb 24 23:39:39 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 24 Feb 2008 16:39:39 -0600 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support In-Reply-To: <20080224233316.11830.2@stippis2.1203879296.fake> References: <200802242117.m1OLHCnh025669@sheep.berlios.de> <20080224233316.11830.2@stippis2.1203879296.fake> Message-ID: > I would hope this were two separate BStrings, because I want the lower > memory footprint and faster operations, like assignement, but not added > overhead to check for duplicate strings. If you happen to know you are > storing the same strings over and over, you could copy them from a global > instance and benefit from the ref counting. Fair enough, I was just curious how far it took things like that, since some of the frameworks that support ref counted strings like Java or .Net support doing things like that (iirc they use a hash lookup to determine if a string already exists, but I may be wrong). I believe on Java you have to manually request that behavior using .intern() though. Thanks for clarifying, Rene From superstippi at gmx.de Sun Feb 24 23:43:01 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 24 Feb 2008 23:43:01 +0100 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support In-Reply-To: References: <200802242117.m1OLHCnh025669@sheep.berlios.de> <20080224233316.11830.2@stippis2.1203879296.fake> Message-ID: <20080224234301.15454.3@stippis2.1203879296.fake> On 2008-02-24 at 23:39:39 [+0100], Rene Gollent wrote: > > I would hope this were two separate BStrings, because I want the lower > > memory footprint and faster operations, like assignement, but not > > added overhead to check for duplicate strings. If you happen to know > > you are storing the same strings over and over, you could copy them > > from a global instance and benefit from the ref counting. > > Fair enough, I was just curious how far it took things like that, since > some of the frameworks that support ref counted strings like Java or .Net > support doing things like that (iirc they use a hash lookup to determine > if a string already exists, but I may be wrong). I believe on Java you > have to manually request that behavior using .intern() though. Well, Julun would know what actually happens, I have not looked at the code myself yet. :-) Best regards, -Stephan From host.haiku at gmx.de Sun Feb 24 23:53:01 2008 From: host.haiku at gmx.de (julun) Date: Sun, 24 Feb 2008 23:53:01 +0100 Subject: [Haiku-commits] r24102 - in haiku/trunk: headers/os/support src/kits/support In-Reply-To: <20080224233316.11830.2@stippis2.1203879296.fake> References: <200802242117.m1OLHCnh025669@sheep.berlios.de> <20080224233316.11830.2@stippis2.1203879296.fake> Message-ID: <47C1F54D.4090007@gmx.de> Stephan Assmus schrieb: > On 2008-02-24 at 22:31:18 [+0100], Rene Gollent wrote: >>> Patch by Julun: implements a refcounted BString. Thank You! >> >> I'm curious, in what circumstances does the refcount come into play? Is >> it only if a string is duplicated via the copy c'tor? Or will something >> like this: >> >> BString a = "This is a test"; >> BString b = "This is a test"; >> >> Also result in two BStrings referring to the same data? > > I would hope this were two separate BStrings, because I want the lower > memory footprint and faster operations, like assignement, but not added > overhead to check for duplicate strings. If you happen to know you are > storing the same strings over and over, you could copy them from a global > instance and benefit from the ref counting. > > Best regards, > -Stephan Hi, i.e, most of the time you just use a BString to store some value and pass it around to some functions that read that value and won't modify the content. In case of the old implementation, passing it to the function would result in allocation the same data for the string used in the function, just to read it an throwaway afterwards. Now it shares the same data which would saves that allocation... If i got everything correct, it would now also be save to create a BString i.e. in main, pass it to two different threads and all share the same storage. Nothing special so far, but in case thread B modifies the string, it would detach and thread B would have it's own modified copy, while main and thread A would still share the same data storage. This should be achieved true the atomic ref counting. Regards, Karsten - aka Julun PS: I would now encourage everyone to use a syntax like this Function(const BString& string) in favor of Function(BString* string) to pass strings to functions :) From bonefish at mail.berlios.de Mon Feb 25 01:55:58 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 25 Feb 2008 01:55:58 +0100 Subject: [Haiku-commits] r24106 - in haiku/trunk: headers/build/os/support src/build/libbe/storage src/build/libbe/storage/mime Message-ID: <200802250055.m1P0twsx003196@sheep.berlios.de> Author: bonefish Date: 2008-02-25 01:55:57 +0100 (Mon, 25 Feb 2008) New Revision: 24106 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24106&view=rev Added: haiku/trunk/headers/build/os/support/TypeConstants.h Removed: haiku/trunk/headers/build/os/support/TypeConstants.h Modified: haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp haiku/trunk/src/build/libbe/storage/NodeInfo.cpp haiku/trunk/src/build/libbe/storage/mime/database_support.cpp Log: Updated headers/build/os/support/TypeConstants.h with the current headers/os version and removed the now duplicate icon type constant definitions from several sources. Deleted: haiku/trunk/headers/build/os/support/TypeConstants.h Copied: haiku/trunk/headers/build/os/support/TypeConstants.h (from rev 24086, haiku/trunk/headers/os/support/TypeConstants.h) Modified: haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2008-02-24 22:35:30 UTC (rev 24105) +++ haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2008-02-25 00:55:57 UTC (rev 24106) @@ -46,8 +46,6 @@ // type codes enum { B_APP_FLAGS_TYPE = 'APPF', - B_MINI_ICON_TYPE = 'MICN', - B_LARGE_ICON_TYPE = 'ICON', B_VERSION_INFO_TYPE = 'APPV', }; Modified: haiku/trunk/src/build/libbe/storage/NodeInfo.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/NodeInfo.cpp 2008-02-24 22:35:30 UTC (rev 24105) +++ haiku/trunk/src/build/libbe/storage/NodeInfo.cpp 2008-02-25 00:55:57 UTC (rev 24106) @@ -32,11 +32,6 @@ static const char *kNIMiniIconAttribute = NI_BEOS ":M:STD_ICON"; static const char *kNILargeIconAttribute = NI_BEOS ":L:STD_ICON"; -// icon types -enum { - B_MINI_ICON_TYPE = 'MICN', - B_LARGE_ICON_TYPE = 'ICON', -}; // constructor /*! \brief Creates an uninitialized BNodeInfo object. Modified: haiku/trunk/src/build/libbe/storage/mime/database_support.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/mime/database_support.cpp 2008-02-24 22:35:30 UTC (rev 24105) +++ haiku/trunk/src/build/libbe/storage/mime/database_support.cpp 2008-02-25 00:55:57 UTC (rev 24106) @@ -29,14 +29,6 @@ #define DBG(x) #define OUT printf -#ifndef HAIKU_HOST_PLATFORM_HAIKU -// icon types (which really ought to be publicly or semi-publicly declared somewhere...) -enum { - B_MINI_ICON_TYPE = 'MICN', - B_LARGE_ICON_TYPE = 'ICON', -}; -#endif - namespace BPrivate { namespace Storage { namespace Mime { From bonefish at mail.berlios.de Mon Feb 25 02:01:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 25 Feb 2008 02:01:42 +0100 Subject: [Haiku-commits] r24107 - haiku/trunk/src/tools/fs_shell Message-ID: <200802250101.m1P11gCW003787@sheep.berlios.de> Author: bonefish Date: 2008-02-25 02:01:41 +0100 (Mon, 25 Feb 2008) New Revision: 24107 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24107&view=rev Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp Log: Patch by Samuel Rodriguez Perez: Fixed building Haiku images on FreeBSD, which was broken since the introduction of the device support. Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-25 00:55:57 UTC (rev 24106) +++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2008-02-25 01:01:41 UTC (rev 24107) @@ -212,6 +212,10 @@ struct stat status; if (fstat(fd, &status) == 0) { + // Do nothing for a regular file + if (S_ISREG(status.st_mode)) + break; + struct disklabel disklabel; off_t mediaSize; From bonefish at mail.berlios.de Mon Feb 25 03:00:14 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 25 Feb 2008 03:00:14 +0100 Subject: [Haiku-commits] r24109 - in haiku/trunk/src: build/libbe/app build/libbe/storage tools tools/fs_shell tools/gensyscalls Message-ID: <200802250200.m1P20ESv010579@sheep.berlios.de> Author: bonefish Date: 2008-02-25 03:00:12 +0100 (Mon, 25 Feb 2008) New Revision: 24109 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24109&view=rev Modified: haiku/trunk/src/build/libbe/app/MessageAdapter.cpp haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp haiku/trunk/src/build/libbe/storage/Entry.cpp haiku/trunk/src/tools/fs_shell/fssh.cpp haiku/trunk/src/tools/gensyscalls/gensyscallinfos.cpp haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp haiku/trunk/src/tools/set_haiku_revision.cpp Log: Patch by Vasilis Kaoutsis: Added missing headers. Fixes the build on certain Linux distributions. Modified: haiku/trunk/src/build/libbe/app/MessageAdapter.cpp =================================================================== --- haiku/trunk/src/build/libbe/app/MessageAdapter.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/build/libbe/app/MessageAdapter.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -6,10 +6,13 @@ * Axel D?rfler, axeld at pinc-software.de * Michael Lotz */ +#include + #include #include #include + namespace BPrivate { #define R5_MESSAGE_FLAG_VALID 0x01 Modified: haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/build/libbe/storage/AppFileInfo.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -9,6 +9,7 @@ #include #include +#include #include #include Modified: haiku/trunk/src/build/libbe/storage/Entry.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/Entry.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/build/libbe/storage/Entry.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -10,6 +10,7 @@ #include #include #include +#include #include #include Modified: haiku/trunk/src/tools/fs_shell/fssh.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/fssh.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/tools/fs_shell/fssh.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -12,6 +12,7 @@ #include #include #include +#include #include Modified: haiku/trunk/src/tools/gensyscalls/gensyscallinfos.cpp =================================================================== --- haiku/trunk/src/tools/gensyscalls/gensyscallinfos.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/tools/gensyscalls/gensyscallinfos.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "gensyscalls_common.h" Modified: haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp =================================================================== --- haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "gensyscalls.h" Modified: haiku/trunk/src/tools/set_haiku_revision.cpp =================================================================== --- haiku/trunk/src/tools/set_haiku_revision.cpp 2008-02-25 01:54:05 UTC (rev 24108) +++ haiku/trunk/src/tools/set_haiku_revision.cpp 2008-02-25 02:00:12 UTC (rev 24109) @@ -9,6 +9,7 @@ #include #include #include +#include #include #include From bonefish at mail.berlios.de Mon Feb 25 02:54:07 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 25 Feb 2008 02:54:07 +0100 Subject: [Haiku-commits] r24108 - in haiku/trunk: headers/libs/alm headers/libs/linprog src/libs/alm src/libs/linprog src/tests/libs/alm src/tests/libs/linprog src/tests/libs/lp_solve Message-ID: <200802250154.m1P1s7ET010317@sheep.berlios.de> Author: bonefish Date: 2008-02-25 02:54:05 +0100 (Mon, 25 Feb 2008) New Revision: 24108 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24108&view=rev Added: haiku/trunk/headers/libs/linprog/Summand.h haiku/trunk/src/libs/linprog/Summand.cpp haiku/trunk/src/tests/libs/alm/SimpleTest.cpp Removed: haiku/trunk/headers/libs/linprog/SoftConstraint.h haiku/trunk/src/libs/linprog/SoftConstraint.cpp Modified: haiku/trunk/headers/libs/alm/Area.h haiku/trunk/headers/libs/alm/BALMLayout.h haiku/trunk/headers/libs/alm/Column.h haiku/trunk/headers/libs/alm/LayoutStyleType.h haiku/trunk/headers/libs/alm/Row.h haiku/trunk/headers/libs/alm/XTab.h haiku/trunk/headers/libs/alm/YTab.h haiku/trunk/headers/libs/linprog/Constraint.h haiku/trunk/headers/libs/linprog/LinearSpec.h haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h haiku/trunk/headers/libs/linprog/OperatorType.h haiku/trunk/headers/libs/linprog/OptimizationType.h haiku/trunk/headers/libs/linprog/PenaltyFunction.h haiku/trunk/headers/libs/linprog/ResultType.h haiku/trunk/headers/libs/linprog/Variable.h haiku/trunk/src/libs/alm/Area.cpp haiku/trunk/src/libs/alm/BALMLayout.cpp haiku/trunk/src/libs/alm/Column.cpp haiku/trunk/src/libs/alm/Row.cpp haiku/trunk/src/libs/alm/XTab.cpp haiku/trunk/src/libs/alm/YTab.cpp haiku/trunk/src/libs/linprog/Constraint.cpp haiku/trunk/src/libs/linprog/Jamfile haiku/trunk/src/libs/linprog/LinearSpec.cpp haiku/trunk/src/libs/linprog/ObjFunctionSummand.cpp haiku/trunk/src/libs/linprog/PenaltyFunction.cpp haiku/trunk/src/libs/linprog/Variable.cpp haiku/trunk/src/tests/libs/alm/Jamfile haiku/trunk/src/tests/libs/alm/TableTest.cpp haiku/trunk/src/tests/libs/alm/Test1.cpp haiku/trunk/src/tests/libs/alm/Test2.cpp haiku/trunk/src/tests/libs/linprog/Jamfile haiku/trunk/src/tests/libs/linprog/Program.cpp haiku/trunk/src/tests/libs/lp_solve/Jamfile Log: Patch by Christof Lutteroth: * copyright headers for the files of the libraries linprog and alm * new class Summand for representing summands in a linear constraint * merged class SoftConstraint into class Constraint; Constraint now supports both soft and hard constraint functionality * new AddConstraint methods in class LinearSpec for directly setting constraints with 1 to 4 summands * code cleanups by using aforementioned AddConstraint methods * a new very simple test application for alm * some style corrections Modified: haiku/trunk/headers/libs/alm/Area.h =================================================================== --- haiku/trunk/headers/libs/alm/Area.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/Area.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef AREA_H #define AREA_H @@ -2,3 +8,2 @@ #include "Constraint.h" -#include "SoftConstraint.h" @@ -26,51 +31,51 @@ public: bool AutoPrefContentSize() const; - void SetAutoPrefContentSize(bool value); + void SetAutoPrefContentSize(bool value); XTab* Left() const; - void SetLeft(XTab* left); + void SetLeft(XTab* left); XTab* Right() const; - void SetRight(XTab* right); + void SetRight(XTab* right); YTab* Top() const; - void SetTop(YTab* top); + void SetTop(YTab* top); YTab* Bottom() const; - void SetBottom(YTab* bottom); + void SetBottom(YTab* bottom); Row* GetRow() const; - void SetRow(Row* row); + void SetRow(Row* row); Column* GetColumn() const; - void SetColumn(Column* column); + void SetColumn(Column* column); BView* Content() const; - void SetContent(BView* content); + void SetContent(BView* content); XTab* ContentLeft() const; YTab* ContentTop() const; XTab* ContentRight() const; YTab* ContentBottom() const; BSize MinContentSize() const; - void SetMinContentSize(BSize min); + void SetMinContentSize(BSize min); BSize MaxContentSize() const; - void SetMaxContentSize(BSize max); + void SetMaxContentSize(BSize max); BSize PrefContentSize() const; - void SetPrefContentSize(BSize pref); + void SetPrefContentSize(BSize pref); BSize ShrinkRigidity() const; - void SetShrinkRigidity(BSize shrink); + void SetShrinkRigidity(BSize shrink); BSize ExpandRigidity() const; - void SetExpandRigidity(BSize expand); + void SetExpandRigidity(BSize expand); double ContentAspectRatio() const; - void SetContentAspectRatio(double ratio); + void SetContentAspectRatio(double ratio); BAlignment Alignment() const; - void SetAlignment(BAlignment alignment); - void SetHAlignment(alignment horizontal); - void SetVAlignment(vertical_alignment vertical); + void SetAlignment(BAlignment alignment); + void SetHAlignment(alignment horizontal); + void SetVAlignment(vertical_alignment vertical); int32 LeftInset() const; - void SetLeftInset(int32 left); + void SetLeftInset(int32 left); int32 TopInset() const; - void SetTopInset(int32 top); + void SetTopInset(int32 top); int32 RightInset() const; - void SetRightInset(int32 right); + void SetRightInset(int32 right); int32 BottomInset() const; - void SetBottomInset(int32 bottom); - void SetDefaultPrefContentSize(); - //~ string ToString(); + void SetBottomInset(int32 bottom); + void SetDefaultPrefContentSize(); + //~ string ToString(); Constraint* HasSameWidthAs(Area* area); Constraint* HasSameHeightAs(Area* area); BList* HasSameSizetAs(Area* area); @@ -84,7 +89,7 @@ Area(BALMLayout* ls, Row* row, Column* column, BView* content, BSize minContentSize); - void DoLayout(); + void DoLayout(); private: void InitChildArea(); @@ -124,8 +129,8 @@ double fContentAspectRatio; Constraint* fContentAspectRatioC; bool fAutoPrefContentSize; - SoftConstraint* fPrefContentWidth; - SoftConstraint* fPrefContentHeight; + Constraint* fPrefContentWidth; + Constraint* fPrefContentHeight; Area* fChildArea; BAlignment fAlignment; int32 fLeftInset; Modified: haiku/trunk/headers/libs/alm/BALMLayout.h =================================================================== --- haiku/trunk/headers/libs/alm/BALMLayout.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/BALMLayout.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef BALM_LAYOUT_H #define BALM_LAYOUT_H Modified: haiku/trunk/headers/libs/alm/Column.h =================================================================== --- haiku/trunk/headers/libs/alm/Column.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/Column.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef COLUMN_H #define COLUMN_H Modified: haiku/trunk/headers/libs/alm/LayoutStyleType.h =================================================================== --- haiku/trunk/headers/libs/alm/LayoutStyleType.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/LayoutStyleType.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef LAYOUT_STYLE_TYPE_H #define LAYOUT_STYLE_TYPE_H Modified: haiku/trunk/headers/libs/alm/Row.h =================================================================== --- haiku/trunk/headers/libs/alm/Row.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/Row.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef ROW_H #define ROW_H Modified: haiku/trunk/headers/libs/alm/XTab.h =================================================================== --- haiku/trunk/headers/libs/alm/XTab.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/XTab.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef X_TAB_H #define X_TAB_H Modified: haiku/trunk/headers/libs/alm/YTab.h =================================================================== --- haiku/trunk/headers/libs/alm/YTab.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/alm/YTab.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef Y_TAB_H #define Y_TAB_H Modified: haiku/trunk/headers/libs/linprog/Constraint.h =================================================================== --- haiku/trunk/headers/libs/linprog/Constraint.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/Constraint.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef CONSTRAINT_H #define CONSTRAINT_H @@ -2,6 +8,9 @@ #include "OperatorType.h" +#include "Variable.h" +#include "ObjFunctionSummand.h" #include #include #include +#include @@ -20,32 +29,51 @@ public: int32 Index(); - BList* Coeffs(); - BList* Vars(); - virtual void ChangeLeftSide(BList* coeffs, BList* vars); - virtual OperatorType Op(); - virtual void SetOp(OperatorType value); + BList* Summands(); + void ChangeLeftSide(BList* summands); + void ChangeLeftSide(double coeff1, Variable* var1); + void ChangeLeftSide(double coeff1, Variable* var1, + double coeff2, Variable* var2); + void ChangeLeftSide(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3); + void ChangeLeftSide(double coeff1, Variable* var1, + double coeff2, Variable* var2, + double coeff3, Variable* var3, + double coeff4, Variable* var4); + OperatorType Op(); + void SetOp(OperatorType value); double RightSide(); - void SetRightSide(double value); + void SetRightSide(double value); + double PenaltyNeg(); + void SetPenaltyNeg(double value); + double PenaltyPos(); + void SetPenaltyPos(double value); + Variable* DNeg() const; + Variable* DPos() const; + BString ToString(); - virtual ~Constraint(); - + ~Constraint(); + protected: - Constraint(); + Constraint(LinearSpec* ls, BList* summands, + OperatorType op, double rightSide, + double penaltyNeg, double penaltyPos); private: - Constraint(LinearSpec* ls, BList* coeffs, BList* vars, - OperatorType op, double rightSide); - -protected: LinearSpec* fLS; - BList* fCoeffs; - BList* fVars; - OperatorType fOp; + BList* fSummands; + OperatorType fOp; double fRightSide; + Variable* fDNeg; + Variable* fDPos; + ObjFunctionSummand* fDNegSummand; + ObjFunctionSummand* fDPosSummand; + + void _UpdateLeftSide(); public: - friend class LinearSpec; + friend class LinearSpec; }; Modified: haiku/trunk/headers/libs/linprog/LinearSpec.h =================================================================== --- haiku/trunk/headers/libs/linprog/LinearSpec.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/LinearSpec.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef LINEAR_SPEC_H #define LINEAR_SPEC_H @@ -10,6 +16,7 @@ #include #include #include +#include namespace LinearProgramming { @@ -17,7 +24,6 @@ class Constraint; class ObjFunctionSummand; class PenaltyFunction; -class SoftConstraint; class Variable; /** @@ -28,81 +34,81 @@ public: LinearSpec(); ~LinearSpec(); - void UpdateObjFunction(); - void SetObjFunction(BList* coeffs, BList* vars); + void UpdateObjFunction(); + void SetObjFunction(BList* summands); ObjFunctionSummand* AddObjFunctionSummand(double coeff, Variable* var); - Variable* AddVariable(); + Variable* AddVariable(); - Constraint* AddConstraint(BList* coeffs, BList* vars, + Constraint* AddConstraint(BList* summands, OperatorType op, double rightSide); Constraint* AddConstraint(double coeff1, Variable* var1, OperatorType op, double rightSide); Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, double coeff3, Variable* var3, OperatorType op, double rightSide); - Constraint* AddConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, double coeff3, Variable* var3, double coeff4, Variable* var4, OperatorType op, double rightSide); - SoftConstraint* AddSoftConstraint(BList* coeffs, BList* vars, + Constraint* AddConstraint(BList* summands, OperatorType op, double rightSide, double penaltyNeg, double penaltyPos); - SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, OperatorType op, double rightSide, double penaltyNeg, double penaltyPos); - SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, OperatorType op, double rightSide, double penaltyNeg, double penaltyPos); - SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, double coeff3, Variable* var3, OperatorType op, double rightSide, double penaltyNeg, double penaltyPos); - SoftConstraint* AddSoftConstraint(double coeff1, Variable* var1, + Constraint* AddConstraint(double coeff1, Variable* var1, double coeff2, Variable* var2, double coeff3, Variable* var3, double coeff4, Variable* var4, OperatorType op, double rightSide, double penaltyNeg, double penaltyPos); - PenaltyFunction* AddPenaltyFunction(Variable* var, BList* xs, BList* gs); - void RemovePresolved(); + PenaltyFunction* AddPenaltyFunction(Variable* var, BList* xs, BList* gs); + void RemovePresolved(); ResultType Presolve(); ResultType Solve(); - void Save(char* fname); + void Save(char* fname); int32 Columns() const; - void SetColumns(int32 value); - OptimizationType Optimization() const; - void SetOptimization(OptimizationType value); + void SetColumns(int32 value); + OptimizationType Optimization() const; + void SetOptimization(OptimizationType value); lprec* LP() const; - void SetLP(lprec* value); + void SetLP(lprec* value); BList* ObjFunctionSummands() const; - void SetObjFunctionSummands(BList* value); + void SetObjFunctionSummands(BList* value); BList* Variables() const; - void SetVariables(BList* value); + void SetVariables(BList* value); BList* Constraints() const; - void SetConstraints(BList* value); + void SetConstraints(BList* value); ResultType Result() const; - void SetResult(ResultType value); + void SetResult(ResultType value); double ObjectiveValue() const; - void SetObjectiveValue(double value); + void SetObjectiveValue(double value); double SolvingTime() const; - void SetSolvingTime(double value); + void SetSolvingTime(double value); protected: int32 fColumns; private: lprec* fLpPresolved; - OptimizationType fOptimization; + OptimizationType fOptimization; lprec* fLP; BList* fObjFunctionSummands; BList* fVariables; @@ -112,8 +118,8 @@ double fSolvingTime; // = Double.Nan public: - friend class ObjFunctionSummand; - friend class SoftConstraint; + friend class ObjFunctionSummand; + friend class Constraint; }; Modified: haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h =================================================================== --- haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/ObjFunctionSummand.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,7 +1,15 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef OBJ_FUNCTION_SUMMAND_H #define OBJ_FUNCTION_SUMMAND_H +#include "Summand.h" + namespace LinearProgramming { class LinearSpec; @@ -10,25 +18,21 @@ /** * A summand of the objective function. */ -class ObjFunctionSummand { +class ObjFunctionSummand : public Summand { public: - double Coeff(); - void SetCoeff(double coeff); - Variable* Var(); - void SetVar(Variable* var); - ~ObjFunctionSummand(); + void SetCoeff(double coeff); + void SetVar(Variable* var); + ~ObjFunctionSummand(); protected: ObjFunctionSummand(LinearSpec* ls, double coeff, Variable* var); private: LinearSpec* fLS; - double fCoeff; - Variable* fVar; public: - friend class LinearSpec; + friend class LinearSpec; }; Modified: haiku/trunk/headers/libs/linprog/OperatorType.h =================================================================== --- haiku/trunk/headers/libs/linprog/OperatorType.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/OperatorType.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef OPERATOR_TYPE_H #define OPERATOR_TYPE_H Modified: haiku/trunk/headers/libs/linprog/OptimizationType.h =================================================================== --- haiku/trunk/headers/libs/linprog/OptimizationType.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/OptimizationType.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef OPTIMIZATION_TYPE_H #define OPTIMIZATION_TYPE_H Modified: haiku/trunk/headers/libs/linprog/PenaltyFunction.h =================================================================== --- haiku/trunk/headers/libs/linprog/PenaltyFunction.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/PenaltyFunction.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef PENALTY_FUNCTION_H #define PENALTY_FUNCTION_H Modified: haiku/trunk/headers/libs/linprog/ResultType.h =================================================================== --- haiku/trunk/headers/libs/linprog/ResultType.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/ResultType.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef RESULT_TYPE_H #define RESULT_TYPE_H Deleted: haiku/trunk/headers/libs/linprog/SoftConstraint.h Added: haiku/trunk/headers/libs/linprog/Summand.h =================================================================== --- haiku/trunk/headers/libs/linprog/Summand.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/Summand.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -0,0 +1,39 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + +#ifndef SUMMAND_H +#define SUMMAND_H + + +namespace LinearProgramming { + +class LinearSpec; +class Variable; + +/** + * A summand of a linear term. + */ +class Summand { + +public: + double Coeff(); + void SetCoeff(double coeff); + Variable* Var(); + void SetVar(Variable* var); + Summand(double coeff, Variable* var); + ~Summand(); + +private: + double fCoeff; + Variable* fVar; + +}; + +} // namespace LinearProgramming + +using LinearProgramming::Summand; + +#endif // OBJ_FUNCTION_SUMMAND_H Modified: haiku/trunk/headers/libs/linprog/Variable.h =================================================================== --- haiku/trunk/headers/libs/linprog/Variable.h 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/headers/libs/linprog/Variable.h 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #ifndef VARIABLE_H #define VARIABLE_H @@ -17,15 +23,15 @@ public: int32 Index(); LinearSpec* LS() const; - void SetLS(LinearSpec* value); + void SetLS(LinearSpec* value); double Value() const; - void SetValue(double value); + void SetValue(double value); double Min() const; - void SetMin(double min); + void SetMin(double min); double Max() const; - void SetMax(double max); - void SetRange(double min, double max); - //~ string ToString(); + void SetMax(double max); + void SetRange(double min, double max); + //~ string ToString(); Constraint* IsEqual(Variable* var); Constraint* IsSmallerOrEqual(Variable* var); Constraint* IsGreaterorEqual(Variable* var); @@ -42,7 +48,7 @@ public: friend class LinearSpec; - friend class SoftConstraint; + friend class Constraint; }; Modified: haiku/trunk/src/libs/alm/Area.cpp =================================================================== --- haiku/trunk/src/libs/alm/Area.cpp 2008-02-25 01:01:41 UTC (rev 24107) +++ haiku/trunk/src/libs/alm/Area.cpp 2008-02-25 01:54:05 UTC (rev 24108) @@ -1,3 +1,9 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth at cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202 at ec.auckland.ac.nz + * Distributed under the terms of the MIT License. + */ + #include "Area.h" #include "Column.h" #include "BALMLayout.h" @@ -71,23 +77,10 @@ fColumn = NULL; if (fChildArea == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fLeft); - vars->AddItem(fRight); - fMinContentWidth->ChangeLeftSide(coeffs, vars); + fMinContentWidth->ChangeLeftSide(-1.0, fLeft, 1.0, fRight); - if (fMaxContentWidth != NULL) { - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fLeft); - vars2->AddItem(fRight); - fMaxContentWidth->ChangeLeftSide(coeffs2, vars2); - } + if (fMaxContentWidth != NULL) + fMaxContentWidth->ChangeLeftSide(-1.0, fLeft, 1.0, fRight); } else UpdateHorizontal(); fLS->InvalidateLayout(); @@ -119,23 +112,10 @@ fColumn = NULL; if (fChildArea == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fLeft); - vars->AddItem(fRight); - fMinContentWidth->ChangeLeftSide(coeffs, vars); + fMinContentWidth->ChangeLeftSide(-1.0, fLeft, 1.0, fRight); - if (fMaxContentWidth != NULL) { - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fLeft); - vars2->AddItem(fRight); - fMaxContentWidth->ChangeLeftSide(coeffs2, vars2); - } + if (fMaxContentWidth != NULL) + fMaxContentWidth->ChangeLeftSide(-1.0, fLeft, 1.0, fRight); } else UpdateHorizontal(); fLS->InvalidateLayout(); @@ -163,23 +143,10 @@ fRow = NULL; if (fChildArea == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fTop); - vars->AddItem(fBottom); - fMinContentHeight->ChangeLeftSide(coeffs, vars); + fMinContentHeight->ChangeLeftSide(-1.0, fTop, 1.0, fBottom); - if (fMaxContentHeight != NULL) { - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fTop); - vars2->AddItem(fBottom); - fMaxContentHeight->ChangeLeftSide(coeffs2, vars2); - } + if (fMaxContentHeight != NULL) + fMaxContentHeight->ChangeLeftSide(-1.0, fTop, 1.0, fBottom); } else UpdateVertical(); fLS->InvalidateLayout(); @@ -207,23 +174,10 @@ fRow = NULL; if (fChildArea == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fTop); - vars->AddItem(fBottom); - fMinContentHeight->ChangeLeftSide(coeffs, vars); + fMinContentHeight->ChangeLeftSide(-1.0, fTop, 1.0, fBottom); - if (fMaxContentHeight != NULL) { - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fTop); - vars2->AddItem(fBottom); - fMaxContentHeight->ChangeLeftSide(coeffs2, vars2); - } + if (fMaxContentHeight != NULL) + fMaxContentHeight->ChangeLeftSide(-1.0, fTop, 1.0, fBottom); } else UpdateVertical(); fLS->InvalidateLayout(); @@ -385,23 +339,11 @@ if (fChildArea == NULL) { fMaxContentSize = max; if (fMaxContentWidth == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fLeft); - vars->AddItem(fRight); - fMaxContentWidth = fLS->AddConstraint(coeffs, vars, OperatorType(LE), + fMaxContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, OperatorType(LE), fMaxContentSize.Width()); fConstraints->AddItem(fMaxContentWidth); - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fTop); - vars2->AddItem(fBottom); - fMaxContentHeight = fLS->AddConstraint(coeffs2, vars2, OperatorType(LE), + fMaxContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, OperatorType(LE), fMaxContentSize.Height()); fConstraints->AddItem(fMaxContentHeight); } else { @@ -435,24 +377,12 @@ if (fChildArea == NULL) { fPrefContentSize = pref; if (fPrefContentWidth == NULL) { - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fLeft); - vars->AddItem(fRight); - fPrefContentWidth = fLS->AddSoftConstraint(coeffs, vars, OperatorType(EQ), + fPrefContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, OperatorType(EQ), fPrefContentSize.Width(), fShrinkRigidity.Width(), fExpandRigidity.Width()); fConstraints->AddItem(fPrefContentWidth); - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fTop); - vars2->AddItem(fBottom); - fPrefContentHeight = fLS->AddSoftConstraint(coeffs2, vars2, OperatorType(EQ), + fPrefContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, OperatorType(EQ), fPrefContentSize.Height(), fShrinkRigidity.Height(), fExpandRigidity.Height()); fConstraints->AddItem(fPrefContentHeight); @@ -536,31 +466,13 @@ if (fChildArea == NULL) { fContentAspectRatio = ratio; if (fContentAspectRatioC == NULL) { - BList* coeffs = new BList(4); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - coeffs->AddItem(new double(ratio)); - coeffs->AddItem(new double(-ratio)); - BList* vars = new BList(4); - vars->AddItem(fLeft); - vars->AddItem(fRight); - vars->AddItem(fTop); - vars->AddItem(fBottom); - fContentAspectRatioC = fLS->AddConstraint(coeffs, vars, - OperatorType(EQ), 0.0); + fContentAspectRatioC = fLS->AddConstraint( + -1.0, fLeft, 1.0, fRight, ratio, fTop, -ratio, fBottom, + OperatorType(EQ), 0.0); fConstraints->AddItem(fContentAspectRatioC); } else { - BList* coeffs2 = new BList(4); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - coeffs2->AddItem(new double(ratio)); - coeffs2->AddItem(new double(-ratio)); - BList* vars2 = new BList(4); - vars2->AddItem(fLeft); - vars2->AddItem(fRight); - vars2->AddItem(fTop); - vars2->AddItem(fBottom); - fContentAspectRatioC->ChangeLeftSide(coeffs2, vars2); + fContentAspectRatioC->ChangeLeftSide( + -1.0, fLeft, 1.0, fRight, ratio, fTop, -ratio, fBottom); } } else fChildArea->SetContentAspectRatio(ratio); @@ -586,7 +498,6 @@ { fAlignment = alignment; UpdateHorizontal(); - fLS->InvalidateLayout(); UpdateVertical(); fLS->InvalidateLayout(); } @@ -751,17 +662,9 @@ Constraint* Area::HasSameWidthAs(Area* area) { - BList* coeffs = new BList(4); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - coeffs->AddItem(new double(1.0)); - coeffs->AddItem(new double(-1.0)); - BList* vars = new BList(4); - vars->AddItem(fLeft); - vars->AddItem(fRight); - vars->AddItem(area->fLeft); - vars->AddItem(area->fRight); - return fLS->AddConstraint(coeffs, vars, OperatorType(EQ), 0.0); + return fLS->AddConstraint( + -1.0, fLeft, 1.0, fRight, 1.0, area->fLeft, -1.0, area->fRight, + OperatorType(EQ), 0.0); } @@ -774,17 +677,9 @@ Constraint* Area::HasSameHeightAs(Area* area) { - BList* coeffs = new BList(4); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - coeffs->AddItem(new double(1.0)); - coeffs->AddItem(new double(-1.0)); - BList* vars = new BList(4); - vars->AddItem(fTop); - vars->AddItem(fBottom); - vars->AddItem(area->fTop); - vars->AddItem(area->fBottom); - return fLS->AddConstraint(coeffs, vars, OperatorType(EQ), 0.0); + return fLS->AddConstraint( + -1.0, fTop, 1.0, fBottom, 1.0, area->fTop, -1.0, area->fBottom, + OperatorType(EQ), 0.0); } @@ -891,23 +786,11 @@ // adds the two essential constraints of the area that make sure that the left x-tab is // really to the left of the right x-tab, and the top y-tab really above the bottom y-tab - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(left); - vars->AddItem(right); - fMinContentWidth = ls->AddConstraint(coeffs, vars, OperatorType(GE), + fMinContentWidth = ls->AddConstraint(-1.0, left, 1.0, right, OperatorType(GE), minContentSize.Width()); fConstraints->AddItem(fMinContentWidth); - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(top); - vars2->AddItem(bottom); - fMinContentHeight = ls->AddConstraint(coeffs2, vars2, OperatorType(GE), + fMinContentHeight = ls->AddConstraint(-1.0, top, 1.0, bottom, OperatorType(GE), minContentSize.Height()); fConstraints->AddItem(fMinContentHeight); } @@ -946,13 +829,13 @@ // coresponding tabs of this area (for a start) fChildArea = new Area(fLS, new XTab(fLS), new YTab(fLS), new XTab(fLS), new YTab(fLS), fContent, BSize(0, 0)); - fLeftConstraint = Left()->IsEqual(fChildArea->Left()); + fLeftConstraint = fLeft->IsEqual(fChildArea->Left()); fConstraints->AddItem(fLeftConstraint); - fTopConstraint = Top()->IsEqual(fChildArea->Top()); + fTopConstraint = fTop->IsEqual(fChildArea->Top()); fConstraints->AddItem(fTopConstraint); - fRightConstraint = Right()->IsEqual(fChildArea->Right()); + fRightConstraint = fRight->IsEqual(fChildArea->Right()); fConstraints->AddItem(fRightConstraint); - fBottomConstraint = Bottom()->IsEqual(fChildArea->Bottom()); + fBottomConstraint = fBottom->IsEqual(fChildArea->Bottom()); fConstraints->AddItem(fBottomConstraint); // remove the minimum content size constraints from this area @@ -972,22 +855,10 @@ fChildArea->fMaxContentSize = fMaxContentSize; fChildArea->fMaxContentWidth = fMaxContentWidth; - BList* coeffs = new BList(2); - coeffs->AddItem(new double(-1.0)); - coeffs->AddItem(new double(1.0)); - BList* vars = new BList(2); - vars->AddItem(fChildArea->Left()); - vars->AddItem(fChildArea->Right()); - fMaxContentWidth->ChangeLeftSide(coeffs, vars); + fMaxContentWidth->ChangeLeftSide(-1.0, fChildArea->Left(), 1.0, fChildArea->Right()); fChildArea->fMaxContentHeight = fMaxContentHeight; - BList* coeffs2 = new BList(2); - coeffs2->AddItem(new double(-1.0)); - coeffs2->AddItem(new double(1.0)); - BList* vars2 = new BList(2); - vars2->AddItem(fChildArea->Top()); - vars2->AddItem(fChildArea->Bottom()); - fMaxContentHeight->ChangeLeftSide(coeffs2, vars2); + fMaxContentHeight->ChangeLeftSide(-1.0, fChildArea->Top(), 1.0, fChildArea->Bottom()); } // if there are preferred content size constraints on this area, @@ -999,22 +870,10 @@ fChildArea->fExpandRigidity = fExpandRigidity; fChildArea->fPrefContentWidth = fPrefContentWidth; - BList* coeffs3 = new BList(2); - coeffs3->AddItem(new double(-1.0)); - coeffs3->AddItem(new double(1.0)); - BList* vars3 = new BList(2); - vars3->AddItem(fChildArea->Left()); - vars3->AddItem(fChildArea->Right()); - fPrefContentWidth->ChangeLeftSide(coeffs3, vars3); + fPrefContentWidth->ChangeLeftSide(-1.0, fChildArea->Left(), 1.0, fChildArea->Right()); fChildArea->fPrefContentHeight = fPrefContentHeight; - BList* coeffs4 = new BList(2); - coeffs4->AddItem(new double(-1.0)); - coeffs4->AddItem(new double(1.0)); [... truncated: 1774 lines follow ...] From korli at users.berlios.de Mon Feb 25 10:10:17 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 25 Feb 2008 10:10:17 +0100 Subject: [Haiku-commits] r24086 - in haiku/trunk/src/bin/tar: . lib lib/uniwidth rmt src In-Reply-To: <2925934647-BeMail@zon> References: <200802232238.m1NMcK6k023129@sheep.berlios.de> <2925934647-BeMail@zon> Message-ID: 2008/2/24, Axel D?rfler : > korli at BerliOS wrote: > > Log: > > updated tar to 1.19 - was harder than expected. > > Any particular problems that you faced? > Yeah, I had to regenerate the config.h, then add needed things to it : #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) #include Bye, J?r?me From revol at free.fr Sun Feb 24 10:38:23 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 24 Feb 2008 10:38:23 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r24086_-_in_haiku/trunk/src/bin/?= =?windows-1252?q?tar=3A_=2E_lib_lib/uniwidth_rmt_src?= In-Reply-To: <200802232238.m1NMcK6k023129@sheep.berlios.de> Message-ID: <547882404-BeMail@laptop> I'm wondering about moving to etar, it supports xattrs, at least in unix. Maybe we can add them to tar though. Fran?ois. From aldeck at mail.berlios.de Mon Feb 25 11:08:28 2008 From: aldeck at mail.berlios.de (aldeck at BerliOS) Date: Mon, 25 Feb 2008 11:08:28 +0100 Subject: [Haiku-commits] r24110 - haiku/trunk/src/preferences/keymap Message-ID: <200802251008.m1PA8SlC028310@sheep.berlios.de> Author: aldeck Date: 2008-02-25 11:08:27 +0100 (Mon, 25 Feb 2008) New Revision: 24110 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=24110&view=rev Modified: haiku/trunk/src/preferences/keymap/KeymapWindow.cpp haiku/trunk/src/preferences/keymap/KeymapWindow.h Log: * rewrote drawing to use an offscreen view * made keys move down when pressed * reduced font size of locks light's text to fit in This fixes #251, style cleanup will follow Modified: haiku/trunk/src/preferences/keymap/KeymapWindow.cpp =================================================================== --- haiku/trunk/src/preferences/keymap/KeymapWindow.cpp 2008-02-25 02:00:12 UTC (rev 24109) +++ haiku/trunk/src/preferences/keymap/KeymapWindow.cpp 2008-02-25 10:08:27 UTC (rev 24110) @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -95,7 +97,7 @@ BDirectory userKeymapsDir(&ref); if (userKeymapsDir.InitCheck() != B_OK) { - create_directory(path.Path(), 0777); + create_directory(path.Path(), S_IRWXU | S_IRWXG | S_IRWXO); } fOpenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), &ref, @@ -442,6 +444,13 @@ fTextView->MakeSelectable(true); AddChild(fTextView); + + fBitmap = new BBitmap(Bounds(), B_RGB32, true, false); + fOffscreenView = new BView(Bounds(), "off_view", 0, 0); + + fBitmap->Lock(); + fBitmap->AddChild(fOffscreenView); + fBitmap->Unlock(); for (uint32 j = 0; j<128; j++) fKeysToDraw[j] = false; @@ -910,262 +919,314 @@ } +MapView::~MapView() +{ + delete fBitmap; +} + + void +MapView::_InitOffscreen() +{ + if (fBitmap->Lock()) { + _DrawBackground(); + fOffscreenView->Sync(); + fBitmap->Unlock(); + } +} + +void MapView::AttachedToWindow() { SetEventMask(B_KEYBOARD_EVENTS, 0); fTextView->SetViewColor(255,255,255); - BView::AttachedToWindow(); + _InitOffscreen(); + + BControl::AttachedToWindow(); } - void -MapView::Draw(BRect rect) -{ - BRect r = Bounds(); - SetHighColor(0,0,0); - StrokeRect(r); +MapView::_DrawBackground(){ + BRect r = fOffscreenView->Bounds(); + fOffscreenView->SetHighColor(0,0,0); + fOffscreenView->StrokeRect(r); r.InsetBySelf(1,1); - SetHighColor(168,168,168); - StrokeRect(r); - SetHighColor(80,80,80); - StrokeLine(BPoint(r.left+2, r.bottom), r.RightBottom()); - StrokeLine(r.RightTop()); + fOffscreenView->SetHighColor(168,168,168); + fOffscreenView->StrokeRect(r); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(BPoint(r.left+2, r.bottom), r.RightBottom()); + fOffscreenView->StrokeLine(r.RightTop()); r.InsetBySelf(1,1); - SetHighColor(255,255,255); - StrokeRect(r); - SetHighColor(112,112,112); - StrokeLine(BPoint(r.left+1, r.bottom), r.RightBottom()); - StrokeLine(r.RightTop()); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeRect(r); + fOffscreenView->SetHighColor(112,112,112); + fOffscreenView->StrokeLine(BPoint(r.left+1, r.bottom), r.RightBottom()); + fOffscreenView->StrokeLine(r.RightTop()); r.InsetBySelf(1,1); - SetHighColor(168,168,168); - FillRect(r); + fOffscreenView->SetHighColor(168,168,168); + fOffscreenView->FillRect(r); - SetHighColor(255,255,255); - FillRect(BRect(r.right-1, r.bottom-1, r.right, r.bottom)); - SetHighColor(184,184,184); - StrokeLine(BPoint(r.right-9, r.bottom), BPoint(r.right-2, r.bottom)); - StrokeLine(BPoint(r.right, r.bottom-9), BPoint(r.right, r.bottom-2)); - - InvalidateKeys(); - + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->FillRect(BRect(r.right-1, r.bottom-1, r.right, r.bottom)); + fOffscreenView->SetHighColor(184,184,184); + fOffscreenView->StrokeLine(BPoint(r.right-9, r.bottom), BPoint(r.right-2, r.bottom)); + fOffscreenView->StrokeLine(BPoint(r.right, r.bottom-9), BPoint(r.right, r.bottom-2)); + // Esc key - DrawBorder(BRect(10,49,30,69)); + _DrawBorder(fOffscreenView, BRect(10,49,30,69)); // Fx keys - DrawBorder(BRect(46, 49, 120, 69)); + _DrawBorder(fOffscreenView, BRect(46, 49, 120, 69)); - DrawBorder(BRect(127, 49, 201, 69)); + _DrawBorder(fOffscreenView, BRect(127, 49, 201, 69)); - DrawBorder(BRect(208, 49, 282, 69)); + _DrawBorder(fOffscreenView, BRect(208, 49, 282, 69)); // Pause, PrintScreen, ... - DrawBorder(BRect(297, 49, 353, 69)); + _DrawBorder(fOffscreenView, BRect(297, 49, 353, 69)); // Insert, pg up ... - DrawBorder(BRect(297, 77, 353, 115)); + _DrawBorder(fOffscreenView, BRect(297, 77, 353, 115)); - SetHighColor(80,80,80); - StrokeLine(BPoint(10,169), BPoint(10,77)); - StrokeLine(BPoint(282,77)); - SetHighColor(255,255,255); - StrokeLine(BPoint(282,169)); - StrokeLine(BPoint(253,169)); - SetHighColor(80,80,80); - StrokeLine(BPoint(253,151)); - SetHighColor(255,255,255); - StrokeLine(BPoint(238,151)); - StrokeLine(BPoint(238,169)); - StrokeLine(BPoint(63,169)); - SetHighColor(80,80,80); - StrokeLine(BPoint(63,151)); - SetHighColor(255,255,255); - StrokeLine(BPoint(39,151)); - StrokeLine(BPoint(39,169)); - StrokeLine(BPoint(11,169)); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(BPoint(10,169), BPoint(10,77)); + fOffscreenView->StrokeLine(BPoint(282,77)); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(BPoint(282,169)); + fOffscreenView->StrokeLine(BPoint(253,169)); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(BPoint(253,151)); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(BPoint(238,151)); + fOffscreenView->StrokeLine(BPoint(238,169)); + fOffscreenView->StrokeLine(BPoint(63,169)); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(BPoint(63,151)); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(BPoint(39,151)); + fOffscreenView->StrokeLine(BPoint(39,169)); + fOffscreenView->StrokeLine(BPoint(11,169)); // Arrows - SetHighColor(80,80,80); - StrokeLine(BPoint(297,169), BPoint(297,149)); - StrokeLine(BPoint(315,149)); - StrokeLine(BPoint(315,131)); - StrokeLine(BPoint(335,131)); - StrokeLine(BPoint(336,149), BPoint(353,149)); - SetHighColor(255,255,255); - StrokeLine(BPoint(335,132), BPoint(335,149)); - StrokeLine(BPoint(353,150), BPoint(353,169)); - StrokeLine(BPoint(298,169)); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(BPoint(297,169), BPoint(297,149)); + fOffscreenView->StrokeLine(BPoint(315,149)); + fOffscreenView->StrokeLine(BPoint(315,131)); + fOffscreenView->StrokeLine(BPoint(335,131)); + fOffscreenView->StrokeLine(BPoint(336,149), BPoint(353,149)); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(BPoint(335,132), BPoint(335,149)); + fOffscreenView->StrokeLine(BPoint(353,150), BPoint(353,169)); + fOffscreenView->StrokeLine(BPoint(298,169)); // numkeys - DrawBorder(BRect(368, 77, 442, 169)); + _DrawBorder(fOffscreenView, BRect(368, 77, 442, 169)); - DrawLocks(); + _DrawLocksBackground(); // the line separator r = BRect(11, 40, 353, 43); - SetHighColor(255,255,255); - StrokeLine(r.LeftBottom(), r.LeftTop()); - StrokeLine(r.RightTop()); - SetHighColor(80,80,80); - StrokeLine(r.RightBottom()); - StrokeLine(r.LeftBottom()); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(r.LeftBottom(), r.LeftTop()); + fOffscreenView->StrokeLine(r.RightTop()); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(r.RightBottom()); + fOffscreenView->StrokeLine(r.LeftBottom()); r.OffsetBySelf(2,4); r.bottom = r.top + 1; - SetHighColor(136,136,136); - FillRect(r); - FillRect(BRect(354,41,355,43)); + fOffscreenView->SetHighColor(136,136,136); + fOffscreenView->FillRect(r); + fOffscreenView->FillRect(BRect(354,41,355,43)); // around the textview - SetHighColor(0,0,0); + fOffscreenView->SetHighColor(0,0,0); r = BRect(11, 13, Bounds().right-11, 31); - StrokeLine(r.LeftBottom(), r.LeftTop()); - StrokeLine(r.RightTop()); - SetHighColor(80,80,80); - StrokeLine(r.LeftBottom()+BPoint(1,0), r.LeftTop()+BPoint(1,1)); - StrokeLine(r.RightTop()+BPoint(0,1)); - SetHighColor(136,136,136); - StrokeLine(r.LeftBottom()+BPoint(2,-1), r.LeftTop()+BPoint(2,2)); - StrokeLine(r.RightTop()+BPoint(0,2)); - StrokeLine(r.LeftBottom()+BPoint(1,0), r.LeftBottom()+BPoint(1,0)); - SetHighColor(255,255,255); - StrokeLine(r.RightTop()+BPoint(0,1), r.RightBottom()); - StrokeLine(r.LeftBottom()+BPoint(2,0)); - BView::Draw(rect); + fOffscreenView->StrokeLine(r.LeftBottom(), r.LeftTop()); + fOffscreenView->StrokeLine(r.RightTop()); + fOffscreenView->SetHighColor(80,80,80); + fOffscreenView->StrokeLine(r.LeftBottom()+BPoint(1,0), r.LeftTop()+BPoint(1,1)); + fOffscreenView->StrokeLine(r.RightTop()+BPoint(0,1)); + fOffscreenView->SetHighColor(136,136,136); + fOffscreenView->StrokeLine(r.LeftBottom()+BPoint(2,-1), r.LeftTop()+BPoint(2,2)); + fOffscreenView->StrokeLine(r.RightTop()+BPoint(0,2)); + fOffscreenView->StrokeLine(r.LeftBottom()+BPoint(1,0), r.LeftBottom()+BPoint(1,0)); + fOffscreenView->SetHighColor(255,255,255); + fOffscreenView->StrokeLine(r.RightTop()+BPoint(0,1), r.RightBottom()); + fOffscreenView->StrokeLine(r.LeftBottom()+BPoint(2,0)); + + _DrawKeysBackground(); + } void -MapView::DrawLocks() -{ - // lights -#define isLighted(i) (fOldKeyInfo.modifiers & i) +MapView::Draw(BRect rect) +{ + // draw the background + if (!fBitmap->Lock()) + return; - DrawBorder(BRect(368, 49, 442, 69)); + if (fOffscreenView->Bounds().Intersects(rect)) { + BRegion region(rect); + ConstrainClippingRegion(®ion); + DrawBitmapAsync(fBitmap, B_ORIGIN); + ConstrainClippingRegion(NULL); + } + + fBitmap->Unlock(); + // draw symbols and lights + for (uint32 i=1; i<=128; i++) + if (fKeysToDraw[i] && rect.Intersects(fKeysRect[i])) + _DrawKey(i); + + if (rect.Intersects(BRect(368, 49, 442, 69))) + _DrawLocksLights(); +} + + +void +MapView::_DrawLocksBackground() +{ + _DrawBorder(fOffscreenView, BRect(368, 49, 442, 69)); + escapement_delta delta; delta.nonspace = 0.0; BFont font(be_p